-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
|
||
|
||
|
||
// ./node_modules/shelljs/bin/shjs PORT_ENV=8090 && node ./test.js | ||
|
||
|
||
// ./node_modules/shelljs/src/exec.js | ||
|
||
// node_modules/shelljs/shell.js |
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,23 @@ | ||
#!/usr/bin/env node | ||
|
||
const shell = require("shelljs"); | ||
|
||
const key = 'PORT_ENV'; | ||
const env = 8888; | ||
|
||
// const command = `export ${key}=${env}`; | ||
// const command = `set ${key}=${env}`; | ||
|
||
const command = 'export PORT_ENV=8888'; | ||
|
||
// shelljs 执行 command | ||
|
||
shell.exec('whoami'); | ||
shell.exec('which sh'); | ||
shell.exec('which bash'); | ||
// shell.exec('pwd'); | ||
// shell.exec('ls -al'); | ||
shell.exec(command); | ||
|
||
console.log('\n command =', command); | ||
console.log('\n PORT_ENV =', process.env.PORT_ENV); |
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,33 @@ | ||
const shell = require("shelljs"); | ||
|
||
const key = 'PORT_ENV'; | ||
const env = 8888; | ||
|
||
// const command = `export ${key}=${env}`; | ||
// const command = `set ${key}=${env}`; | ||
|
||
// 命令 & 参数 分隔符号 | ||
// const command = 'export "PORT_ENV=8888"'; | ||
const command = 'export PORT_ENV=8888'; | ||
|
||
// shelljs 执行 command | ||
|
||
shell.exec('whoami'); | ||
shell.exec('which sh'); | ||
shell.exec('which bash'); | ||
// shell.exec('pwd'); | ||
// shell.exec('ls -al'); | ||
shell.exec(command); | ||
// shell.exec('export', 'PORT_ENV=8888'); | ||
|
||
// ??? (追加)写入到 .zshrc 文件 | ||
// export PORT_ENV="8888" | ||
// source ~/.profile | ||
// source ~/.bash_profile | ||
|
||
// export ZSH="/Users/xgqfrms/.oh-my-zsh" | ||
|
||
|
||
|
||
console.log('\n command =', command); | ||
console.log('\n PORT_ENV =', process.env.PORT_ENV); |