actionhero
Version:
actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks
29 lines (23 loc) • 719 B
JavaScript
const fs = require('fs')
const path = require('path')
const optimist = require('optimist')
const argv = optimist
.demand('name')
.describe('name', 'The name of the action')
.describe('description', 'The description of the action')
.default('description', 'My Action')
.argv
module.exports = function (api, next) {
let data = fs.readFileSync(path.join(__dirname, '/../../templates/action.js'))
data = String(data);
[
'name',
'description'
].forEach(function (v) {
let regex = new RegExp('%%' + v + '%%', 'g')
data = data.replace(regex, argv[v])
})
api.utils.createFileSafely(api.config.general.paths.action[0] + '/' + argv.name + '.js', data)
next(null, true)
}