Repository URL to install this package:
|
Version:
1.10.1 ▾
|
@doodle/doodle-node-cli
/
cli.js
|
|---|
#!/usr/bin/env node
const fs = require('fs');
const argv = require('minimist')(process.argv.slice(2));
const updateNotifier = require('update-notifier');
const doodleNodeCli = require('.');
const initConfiguration = require('./src/prompts/init-prompt');
const { CONFIGURATION_FILE, ENTITY_NOT_FOUND } = require('./src/constants');
const pkg = require('./package.json');
updateNotifier({ pkg }).notify({ isGlobal: true });
// Attempt to read in the configuration file,
// otherwise, run the user through the initConfiguration
// steps to generate the file
try {
const config = fs.readFileSync(CONFIGURATION_FILE);
doodleNodeCli(argv._, argv, JSON.parse(config));
} catch (err) {
if (err.code && err.code === ENTITY_NOT_FOUND) {
console.log(
'A basic configuration is needed before start using the cli (you only need to answer these questions once):'
);
initConfiguration();
} else {
throw err;
}
}