srap/bin/execute

32 lines
708 B
Plaintext
Raw Normal View History

2021-10-09 20:16:34 +02:00
#!/usr/bin/env node
"use strict";
const Promise = require("bluebird");
const yargs = require("yargs");
const path = require("path");
const createKernel = require("../src/kernel");
const chalk = require("chalk");
let argv = yargs.argv;
let [ configurationPath, task, item ] = argv._;
2022-03-04 03:18:21 +01:00
let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
2021-10-09 20:16:34 +02:00
let configuration = require(absoluteConfigurationPath);
return Promise.try(() => {
return createKernel(configuration);
}).then((kernel) => {
return Promise.try(() => {
return kernel.execute({
task: task,
itemID: item
});
}).then(() => {
console.log(chalk.green.bold("Done!"));
}).finally(() => {
kernel.shutdown();
});
});