Skip to content

Commit

Permalink
shell.exec(command); bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xgqfrms committed Oct 14, 2021
1 parent 3936254 commit cb12a9c
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bug.js
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
23 changes: 23 additions & 0 deletions spe-bug
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);
33 changes: 33 additions & 0 deletions spe-bug.js
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);

0 comments on commit cb12a9c

Please sign in to comment.