Skip to content

Commit

Permalink
fix: fix dev script.
Browse files Browse the repository at this point in the history
  • Loading branch information
100pah committed Nov 18, 2019
1 parent 972cc8f commit 6531a9d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
26 changes: 18 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,40 @@ var argv = require('yargs').argv;
* Usage:
*
* ```shell
* ./nodule_modules/.bin/gulp release --env asf
* ./nodule_modules/.bin/gulp release --env echartsjs
* ./nodule_modules/.bin/gulp release --env dev # the same as "debug"
* ./node_modules/.bin/gulp release --env asf
* ./node_modules/.bin/gulp release --env echartsjs
* ./node_modules/.bin/gulp release --env dev # the same as "debug"
* # Check `./config` to see the available env
* ```
* ------------------------------------------------------------------------
*/

function initEnv() {
var envType = argv.env;
var isDev = argv.dev != null || argv.debug != null || envType === 'debug';
var isDev = argv.dev != null || argv.debug != null || envType === 'debug' || envType === 'dev';

if (isDev) {
console.warn('=============================');
console.warn('!!! THIS IS IN DEV MODE !!!');
console.warn('=============================');
console.warn('====================================================================');
console.warn('THIS IS IN DEV MODE');
console.warn('!!! Please input your local host in `config/env.dev.js` firstly !!!');
console.warn('====================================================================');
envType = 'dev';
}

if (!envType) {
throw new Error('--env MUST be specified');
}

return require('./config/env.' + envType);
var config = require('./config/env.' + envType);

if (isDev) {
console.warn('====================================================================');
console.warn('Please visit the website: ');
console.warn(config.host);
console.warn('====================================================================');
}

return config;
}

var config = initEnv();
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "echarts-examples",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "./node_modules/.bin/gulp release --env dev"
},
"devDependencies": {
"app-module-path": "^2.2.0",
"argparse": "^1.0.9",
Expand Down

0 comments on commit 6531a9d

Please sign in to comment.