Skip to content

Commit

Permalink
perf(edam-cli): allow to run command 'edam' without '-o, --output'
Browse files Browse the repository at this point in the history
  • Loading branch information
imcuttle committed Jun 1, 2018
1 parent 8d09a51 commit 550667e
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions packages/edam-cli/bin/edam.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const flags = [
{
name: 'cache-dir',
type: 'string',
desc: 'Appoints to the cache where to store. It should be a directory path.',
desc:
'Appoints to the cache where to store. It should be a directory path.',
default: tildify(constant.DEFAULT_CACHE_DIR)
},
{
Expand All @@ -41,8 +42,8 @@ const flags = [
name: 'extends',
type: 'string',
desc:
'Extends external edam configuration files. ' +
'eg. --extends="./.edamrc,../.edamrc"',
'Extends external edam configuration files. ' +
'eg. --extends="./.edamrc,../.edamrc"',
default: null
},
{
Expand All @@ -54,7 +55,8 @@ const flags = [
{
name: 'pull.npmClient',
type: 'string',
desc: 'Appoints to the command when installing package form npmjs.com. [npm|yarn]',
desc:
'Appoints to the command when installing package form npmjs.com. [npm|yarn]',
default: 'npm'
},
{
Expand All @@ -66,7 +68,8 @@ const flags = [
{
name: 'userc',
type: 'boolean',
desc: 'Edam can deduce the configuration file from current work directory like `.babelrc`.',
desc:
'Edam can deduce the configuration file from current work directory like `.babelrc`.',
default: true
},
{
Expand Down Expand Up @@ -120,20 +123,17 @@ ${generateFlagHelp(flags, ' ')}
{
flags: generateFlagData(flags),
autoHelp: false,
description: ` ${c.cyan.bold(
pkg.description
)} ${c.gray(pkg.version)}`
description: ` ${c.cyan.bold(pkg.description)} ${c.gray(pkg.version)}`
}
)

)
;(function() {
if (cli.flags.help) {
cli.showHelp()
return
}

const flags = cli.flags
// parse array input
// parse array input
;['extends', 'plugins'].forEach(name => {
if (!Array.isArray(flags[name])) {
if (flags[name]) {
Expand Down Expand Up @@ -174,7 +174,6 @@ ${generateFlagHelp(flags, ' ')}
delete config.output
}


let spinner = require('ora')()
const em = edam(config, {
cwd: process.cwd()
Expand Down Expand Up @@ -204,7 +203,8 @@ ${generateFlagHelp(flags, ' ')}
// console.log(process._getActiveHandles())
// console.log(process._getActiveRequests().length)

!em.config.silent && spinner.start(`Pulling template from ${source.type}: ${source.url}`)
!em.config.silent &&
spinner.start(`Pulling template from ${source.type}: ${source.url}`)
}
})
.on('pull:after', templateConfigPath => {
Expand Down Expand Up @@ -232,7 +232,16 @@ ${generateFlagHelp(flags, ' ')}
//
let code = 0
em
.run()
.ready()
.then(() => {
if (!em.config.output) {
em.config.output = process.cwd()
}

return em.checkConfig()
})
.then(() => em.pull())
.then(() => em.process())
.then(function(fp) {
return fp.writeToFile(void 0, { overwrite: flags.overwrite })
})
Expand All @@ -251,13 +260,13 @@ ${generateFlagHelp(flags, ' ')}
if (upt) {
notifier.notify({
message:
'Update available ' +
c.dim(upt.current) +
c.reset(' → ') +
c.green(upt.latest) +
' \nRun ' +
c.cyan('npm install edam@latest -g') +
' to update'
'Update available ' +
c.dim(upt.current) +
c.reset(' → ') +
c.green(upt.latest) +
' \nRun ' +
c.cyan('npm install edam@latest -g') +
' to update'
})
}
}
Expand Down

0 comments on commit 550667e

Please sign in to comment.