-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
egg-bin autod --check
command (#70)
* chore: remove hotfix spawn-wrap codest
- Loading branch information
Showing
10 changed files
with
90 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const Command = require('../command'); | ||
|
||
class AutodCommand extends Command { | ||
constructor(rawArgv) { | ||
super(rawArgv); | ||
this.usage = 'Usage: egg-bin autod'; | ||
this.options = { | ||
check: { | ||
description: 'dependencies checker', | ||
}, | ||
}; | ||
} | ||
|
||
get description() { | ||
return 'Generate pkg.dependencies and pkg.devDependencies automatically'; | ||
} | ||
|
||
* run({ cwd, argv }) { | ||
const args = []; | ||
if (argv.check) args.push('--check'); | ||
const autodBin = require.resolve('autod/bin/autod.js'); | ||
yield this.helper.forkNode(autodBin, args, { cwd }); | ||
} | ||
} | ||
|
||
module.exports = AutodCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
require('urllib'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "autod-exists", | ||
"dependencies": { | ||
"urllib": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
require('urllib'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "autod-missing" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const coffee = require('coffee'); | ||
|
||
const eggBin = require.resolve('../../../bin/egg-bin.js'); | ||
|
||
describe('test/lib/cmd/autod.test.js', () => { | ||
it('should autod check fail', function* () { | ||
const cwd = path.join(__dirname, '../../fixtures/autod-missing'); | ||
yield coffee.fork(eggBin, [ 'autod', '--check' ], { cwd }) | ||
.debug() | ||
.expect('code', 1) | ||
.expect('stderr', /\[ERROR\] Missing dependencies: \["urllib"\]/) | ||
.end(); | ||
}); | ||
|
||
it('should autod check pass', function* () { | ||
const cwd = path.join(__dirname, '../../fixtures/autod-exists'); | ||
yield coffee.fork(eggBin, [ 'autod', '--check' ], { cwd }) | ||
.debug() | ||
.expect('code', 0) | ||
.end(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters