Name: egg-bin
Owner: egg
Description: egg developer tool
Created: 2016-06-18 06:59:02.0
Updated: 2018-05-12 09:40:27.0
Pushed: 2018-04-18 03:29:38.0
Size: 287
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
egg developer tool, extends common-bin.
m i egg-bin --save-dev
Add egg-bin
to package.json
scripts:
cripts": {
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test-local": "egg-bin test",
"test": "npm run lint -- --fix && npm run test-local",
"cov": "egg-bin cov",
"lint": "eslint .",
"pkgfiles": "egg-bin pkgfiles",
"autod": "egg-bin autod",
"ci": "npm run lint && npm run autod -- --check && npm run pkgfiles -- --check && npm run cov"
All the commands support these specific v8 options:
--debug
--inspect
--harmony*
--es_staging
g-bin [command] --debug --es_staging
if process.env.NODE_DEBUG_OPTION
is provided (WebStorm etc), will use it as debug options.
Start dev cluster on local
env, it will start a master, an agent and a worker.
g-bin dev
--framework
egg web framework root path.--baseDir
application's root path, default to process.cwd()
.--port
server port, default to 7001
.--cluster
worker process number, skip this argvs will start only 1
worker, provide this without value will start cpu
count worker.--sticky
start a sticky cluster server, default to false
.--typescript
/ --ts
enable typescript support, default to false
. Also support read from package.json
's egg.typescript
.--require
will add to execArgv
, support multiple.Debug egg app with V8 Inspector Integration.
automatically detect the protocol, use the new inspector
when the targeted runtime >=7.0.0 .
if running without VSCode
or WebStorm
, we will use inspector-proxy to proxy worker debug, so you don't need to worry about reload.
g-bin debug --debug-port=9229 --proxy=9999
egg-bin dev
options is accepted.--proxy=9999
worker debug proxy port.Using mocha with co-mocha to run test.
power-assert is the default assert
library, and intelli-espower-loader will be auto required.
g-bin test [files] [options]
files
is optional, default to test/**/*.test.js
test/fixtures
, test/node_modules
is always exclude.test/.setup.js
If test/.setup.js
file exists, it will be auto require as the first test file.
? .setup.js
? foo.test.js
You can pass any mocha argv.
--require
require the given module--grep
only run tests matching --timeout
milliseconds, default to 30000--full-trace
display the full stack trace, default to false.--typescript
/ --ts
enable typescript support, default to false
.Environment is also support, will use it if options not provide.
You can set TESTS
env to set the tests directory, it support glob grammar.
S=test/a.test.js egg-bin test
And the reporter can set by the TEST_REPORTER
env, default is spec
.
_REPORTER=doc egg-bin test
The test timeout can set by TEST_TIMEOUT
env, default is 30000
ms.
_TIMEOUT=2000 egg-bin test
Using [nyc] to run code coverage, it support all test params above.
Coverage reporter will output text-summary, json and lcov.
You can pass any mocha argv.
-x
add dir ignore coverage, support multiple argv--prerequire
prerequire files for coverage instrument, you can use this options if load files slowly when call mm.app
or mm.cluster
--typescript
/ --ts
enable typescript support, default to false
, if true, will auto add .ts
extension and ignore typings
and d.ts
.You can set COV_EXCLUDES
env to add dir ignore coverage.
V_EXCLUDES="app/plugins/c*,app/autocreate/**" egg-bin cov
Generate pkg.files
automatically before npm publish, see ypkgfiles for detail
g-bin pkgfiles
Generate pkg.dependencies
and pkg.devDependencies
automatically, see autod for detail
g-bin autod
You maybe need a custom egg-bin to implement more custom features if your team has develop a framework base on egg.
Now you can implement a Command sub class to do that. Or you can just override the exists command.
See more at common-bin.
nsp has provide a useful security scan feature.
This example will show you how to add a new NspCommand
to create a new egg-bin
tool.
t EggBinCommand = require('egg-bin');
s MyEggBinCommand extends EggBinCommand {
nstructor(rawArgv) {
super(rawArgv);
this.usage = 'Usage: egg-bin [command] [options]';
// load directory
this.load(path.join(__dirname, 'lib/cmd'));
le.exports = MyEggBinCommand;
t Command = require('egg-bin').Command;
s NspCommand extends Command {
run({ cwd, argv }) {
console.log('run nsp check at %s with %j', cwd, argv);
scription() {
return 'nsp check';
le.exports = NspCommand;
sr/bin/env node
strict';
t Command = require('..');
Command().start();
-egg-bin nsp
nsp check at /foo/bar with {}