Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ========================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/cat.js
// ========================================================================
var output_file = function(file: string) {
cli.withInput(file, function (line, sep, eof) {
if (!eof) {
cli.output(line + sep);
} else if (cli.args.length) {
output_file(cli.args.shift());
}
});
};
if (cli.args.length) {
output_file(cli.args.shift());
}
// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/command.js
// ============================================================================
cli.parse(null, ['install', 'test', 'edit', 'remove', 'uninstall', 'ls']);
console.log('Command is: ' + cli.command);
// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/echo.js
// ============================================================================
const config = require('./config/config.json');
const cli = require('cli');
var shared = require('./shared');
// parse args
let args = cli.args;
if(args.length > 0){
args = args[0];
}
// Build docs
if(args === 'build'){
shared.build(function(){
console.log("[INFO] Successfully built");
process.exit(0);
});
}else if(args === 'serve'){
require("./server")
}else{
console.log("[ERROR] No option selected. Valid options are: build, serve");
}
cli.main(function(args, options){
var tf = new TerraformRunner(options.workdir);
if(cli.command == 'init') {
tf.init();
} else if(cli.command == 'destroy') {
tf.destroy();
} else if(cli.command == 'force-unlock') {
tf.unlock(args[0]);
} else if(cli.command == 'state') {
tf.state(function() {
// test
var testRunner = new TestRunner(options.tests);
testRunner.run();
});
} else if(cli.command == 'apply') {
tf.apply(function(callback) {
if(!options.skipTests) {
// test
var testRunner = new TestRunner(options.tests);
testRunner.run();
} else {
console.log("Skipping tests...");
}
;
console.log('This scriprt is not working now. Should be fixed.');
cli.exit(1);
if (!to || !from) {
cli.error('"to" and "from" options are required.\n');
cli.output(cli.getUsage());
cli.exit(1);
return ;
}
var mongoUri = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || process.env.MONGO_URI || false;
if (!mongoUri) {
cli.error('Please set MONGO_URI env.\n');
cli.output(cli.getUsage());
cli.exit(1);
return;
}
mongo.connect(mongoUri);
// あー config 読み込み&model読み込み周りを app.js から切り離さないといけないにゃぁ
configModel = require('../lib/models/config')(app);
async.series([
function (next) {
configModel.loadAllConfig(function(err, doc) {
return next();
});
}, function (next) {
#!/usr/bin/env node
var cli = require('cli');
//The second (optional) argument of cli.parse() is a command list
//Type `./command.js --help` for usage info
//cli enables auto-completion of commands (similiar to npm), e.g. all of
//the following are equivalent and result in "Command is: install":
// $ ./command.js install
// $ ./command.js inst
// $ ./command.js i
cli.parse(null, ['install', 'test', 'edit', 'remove', 'uninstall', 'ls']);
console.log('Command is: ' + cli.command);
// Reporter that displays additional JSHint data
case options["show-non-errors"]:
options.reporter = "../reporters/non_error.js";
break;
// Custom reporter
case options.reporter !== undefined:
options.reporter = path.resolve(process.cwd(), options.reporter);
}
var reporter;
if (options.reporter) {
reporter = loadReporter(options.reporter);
if (reporter === null) {
cli.error("Can't load reporter file: " + options.reporter);
process.exit(1);
}
}
var passed = exports.run({
args: cli.args,
config: config,
reporter: reporter,
ignores: loadIgnores(),
extensions: options["extra-ext"],
verbose: options.verbose
});
// Patch as per https://github.com/visionmedia/mocha/issues/333
// fixes issues with piped output on Windows.
// Root issue is here https://github.com/joyent/node/issues/3584
let compiledContract = solc.compile(source, 1);
let abi = compiledContract.contracts[':Fundraiser'].interface;
let bytecode = compiledContract.contracts[':Fundraiser'].bytecode;
let MyContract = web3.eth.contract(JSON.parse(abi));
// Fundraiser takes some arguments to assign control and begin/end blocks
cli.parse({
admin: [ 'a', 'Admin address', 'string', "" ],
treasury: [ 't', 'Treasury address', 'string', ""],
begin: [ 'b', 'Begin block', 'int', 0],
end: [ 'e', 'End block', 'int', 0],
weiPerAtom: [ 'r', 'Initial atom rate', 'int', 0],
});
var admin = cli.options.admin;
var treasury = cli.options.treasury;
var beginBlock = cli.options.begin;
var endBlock = cli.options.end;
var weiPerAtom = cli.options.weiPerAtom;
// output the gas and tx data to deploy the contract
var deployData = MyContract.new.getData(admin, treasury, beginBlock, endBlock, weiPerAtom, {data:bytecode});
txObject = {
gas: 800000,
data: "0x"+deployData
}
console.log(JSON.stringify(txObject));
let bytecode = compiledContract.contracts[':Fundraiser'].bytecode;
let MyContract = web3.eth.contract(JSON.parse(abi));
// Fundraiser takes some arguments to assign control and begin/end blocks
cli.parse({
admin: [ 'a', 'Admin address', 'string', "" ],
treasury: [ 't', 'Treasury address', 'string', ""],
begin: [ 'b', 'Begin block', 'int', 0],
end: [ 'e', 'End block', 'int', 0],
weiPerAtom: [ 'r', 'Initial atom rate', 'int', 0],
});
var admin = cli.options.admin;
var treasury = cli.options.treasury;
var beginBlock = cli.options.begin;
var endBlock = cli.options.end;
var weiPerAtom = cli.options.weiPerAtom;
// output the gas and tx data to deploy the contract
var deployData = MyContract.new.getData(admin, treasury, beginBlock, endBlock, weiPerAtom, {data:bytecode});
txObject = {
gas: 800000,
data: "0x"+deployData
}
console.log(JSON.stringify(txObject));
bundle.addEntry("./src/stable/jshint.js");
if (!test("-e", "./dist")) {
mkdir("./dist");
}
echo("Building into dist/...", "\n");
bundle.append("JSHINT = require('/src/stable/jshint.js').JSHINT;");
[ "// " + pkg.version,
"var JSHINT;",
bundle.bundle()
].join("\n").to("./dist/jshint-" + pkg.version + ".js");
cli.ok("Bundle");
// Rhino
var rhino = cat("./dist/jshint-" + pkg.version + ".js", "./src/platforms/rhino.js");
rhino = "#!/usr/bin/env rhino\n\n" + rhino;
rhino.to("./dist/jshint-rhino-" + pkg.version + ".js");
exec("chmod +x dist/jshint-rhino-" + pkg.version + ".js");
cli.ok("Rhino");
echo("\n");
};
// This is a hack. exports.run is both sync and async function
// because I needed stdin support (and cli.withStdin is async)
// and was too lazy to change tests.
function done(passed) {
/*jshint eqnull:true */
if (passed == null)
return;
exports.exit(passed ? 0 : 2);
}
done(exports.run({
args: cli.args,
config: config,
reporter: reporter,
ignores: loadIgnores({exclude: options.exclude, excludePath: options["exclude-path"]}),
extensions: options["extra-ext"],
verbose: options.verbose,
extract: options.extract,
filename: options.filename,
useStdin: {"-": true, "/dev/stdin": true}[args[args.length - 1]]
}, done));
}
};