Skip to content

Commit 472a931

Browse files
kaylieEBarcanis
kaylieEB
authored andcommitted
Add yarn run env script (#3596)
* Add env script * use process.env instead of printenv
1 parent b9fe983 commit 472a931

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

__tests__/commands/run.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ test('properly handle bin scripts', (): Promise<void> => {
7575
});
7676
});
7777

78+
test('properly handle env command', (): Promise<void> => {
79+
return runRun(['env'], {}, 'no-args', (config, reporter): ?Promise<void> => {
80+
const rprtr = new reporters.BufferReporter({stdout: null, stdin: null});
81+
82+
rprtr.info(`${JSON.stringify(process.env, null, 2)}`);
83+
84+
expect(reporter.getBuffer()).toEqual(rprtr.getBuffer());
85+
});
86+
});
87+
7888
test('retains string delimiters if args have spaces', (): Promise<void> => {
7989
return runRun(['cat-names', '--filter', 'cat names'], {}, 'bin', config => {
8090
const script = path.join(config.cwd, 'node_modules', '.bin', 'cat-names');

src/cli/commands/run.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
8383
const cmdWithArgs = stage === action ? defaultScriptCmd : cmd;
8484
await execCommand(stage, config, cmdWithArgs, config.cwd);
8585
}
86+
} else if (action === 'env') {
87+
reporter.info(`${JSON.stringify(process.env, null, 2)}`);
8688
} else {
8789
let suggestion;
8890

0 commit comments

Comments
 (0)