-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'alibaba-fusion:master' into menu#4640
- Loading branch information
Showing
15 changed files
with
8,820 additions
and
63 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,65 @@ | ||
const path = require('path'); | ||
const cp = require('child_process'); | ||
const parseArgs = require('minimist'); | ||
const { checkComponentName } = require('../../utils'); | ||
|
||
const scriptPath = path.join(__dirname, 'server.js'); | ||
|
||
const args = checkComponentName(false, true); | ||
|
||
// 获取输入的 mode,css / scss,默认scss | ||
// const mode = process.env.npm_config_mode || 'scss'; | ||
// args.push(mode); | ||
|
||
const argv = parseArgs(args); | ||
|
||
argv._.forEach(item => { | ||
if (item.indexOf('=') > -1) { | ||
const key = item.split('=')[0]; | ||
const value = item.split('=')[1]; | ||
argv[key] = value; | ||
} | ||
}); | ||
|
||
start(restoreArgs(argv)); | ||
|
||
function start(args) { | ||
const worker = cp.fork(scriptPath, args); | ||
|
||
hanleMsg(worker); | ||
function hanleMsg(worker) { | ||
worker.on('message', data => { | ||
if (data === 'RESTART') { | ||
worker.kill('SIGINT'); | ||
start(args); | ||
} else if (data.indexOf('CHANGE_LANG') === 0) { | ||
worker.kill('SIGINT'); | ||
const lang = data.split('=')[1]; | ||
const argv = parseArgs(args); | ||
argv.lang = lang; | ||
const newArgs = restoreArgs(argv); | ||
start(newArgs); | ||
} else if (data.indexOf('CHANGE_DIR') === 0) { | ||
worker.kill('SIGINT'); | ||
const dir = data.split('=')[1]; | ||
const argv = parseArgs(args); | ||
argv.dir = dir; | ||
const newArgs = restoreArgs(argv); | ||
start(newArgs); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function restoreArgs(argv) { | ||
return Object.keys(argv).reduce((ret, key) => { | ||
let arr; | ||
if (key === '_') { | ||
arr = argv._; | ||
} else { | ||
arr = [`--${key}`, argv[key]]; | ||
} | ||
|
||
return ret.concat(arr); | ||
}, []); | ||
} |
Oops, something went wrong.