@whook/example
Version:
A basic Whook server
47 lines (39 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.definition = void 0;
var _knifecycle = require("knifecycle");
var _args = require("@whook/cli/dist/libs/args");
const definition = {
description: 'A command printing every env values',
example: `whook printEnv --name NODE_ENV`,
arguments: {
type: 'object',
additionalProperties: false,
required: [],
properties: {
keysOnly: {
description: 'Option to print only env keys',
type: 'boolean'
}
}
}
};
exports.definition = definition;
var _default = (0, _knifecycle.extra)(definition, (0, _knifecycle.service)(initPrintEnvCommand, "printEnvCommand", ["ENV", "log", "args"])); // Commands are a simple way to write utility scripts that leverage
// your application setup. It allows to simply inject services
// without worrying about their initialization.
exports.default = _default;
async function initPrintEnvCommand({
ENV,
log,
args
}) {
return async () => {
const {
keysOnly
} = (0, _args.readArgs)(definition.arguments, args);
log('info', `${JSON.stringify(keysOnly ? Object.keys(ENV) : ENV)}`);
};
}