Sha256: 44c7f9aea411e862985992542e1d52ecf2a72037751fab38e3f7d0837651d1af

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.printEND = exports.printBEGIN = void 0;
const prettier_1 = __importDefault(require("../../prettier"));
const { group, indent, line } = prettier_1.default;
// The `BEGIN` and `END` keywords are used to hook into the Ruby process. Any
// `BEGIN` blocks are executed right when the process starts up, and the `END`
// blocks are executed right before exiting.
//
//     BEGIN {
//       # content goes here
//     }
//
//     END {
//       # content goes here
//     }
//
// Interesting side note, you don't use `do...end` blocks with these hooks. Both
// nodes contain one child which is a `stmts` node.
function printHook(name) {
    return function printHookWithName(path, opts, print) {
        return group([
            name,
            " ",
            path.call(print, "body", 0),
            indent([line, path.call(print, "body", 1)]),
            [line, "}"]
        ]);
    };
}
exports.printBEGIN = printHook("BEGIN");
exports.printEND = printHook("END");

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
prettier-2.0.0 dist/ruby/nodes/hooks.js
prettier-2.0.0.pre.rc4 dist/ruby/nodes/hooks.js
prettier-2.0.0.pre.rc3 dist/ruby/nodes/hooks.js
prettier-2.0.0.pre.rc2 dist/ruby/nodes/hooks.js
prettier-2.0.0.pre.rc1 dist/ruby/nodes/hooks.js