Skip to content

Commit 9539ba2

Browse files
authored
fix: remove dash from environment variables (#195)
1 parent 3b4b884 commit 9539ba2

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/run-script.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function getEnv() {
4747
return envCopy
4848
},
4949
{
50-
[`SCRIPTS_${script.toUpperCase()}`]: true,
50+
[`SCRIPTS_${script.toUpperCase().replace(/-/g, '_')}`]: true,
5151
},
5252
)
5353
}

src/scripts/__tests__/__snapshots__/test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports[`test does not watch --updateSnapshot 1`] = `--config {"builtInConfig":t
66

77
exports[`test does not watch on CI 1`] = `--config {"builtInConfig":true}`;
88

9-
exports[`test does not watch on SCRIPTS_PRE-COMMIT 1`] = `--config {"builtInConfig":true}`;
9+
exports[`test does not watch on SCRIPTS_PRE_COMMIT 1`] = `--config {"builtInConfig":true}`;
1010

1111
exports[`test does not watch with --coverage 1`] = `--config {"builtInConfig":true} --coverage`;
1212

src/scripts/__tests__/test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ cases(
2424
const {run: jestRunMock} = require('jest')
2525
const originalArgv = process.argv
2626
const prevCI = mockIsCI
27-
const prevPreCommit = process.env['SCRIPTS_PRE-COMMIT']
27+
const prevPreCommit = process.env.SCRIPTS_PRE_COMMIT
2828
mockIsCI = ci
29-
process.env['SCRIPTS_PRE-COMMIT'] = preCommit
29+
process.env.SCRIPTS_PRE_COMMIT = preCommit
3030
Object.assign(utils, {
3131
hasPkgProp: () => pkgHasJestProp,
3232
hasFile: () => hasJestConfigFile,
@@ -50,7 +50,7 @@ cases(
5050
// afterEach
5151
process.argv = originalArgv
5252
mockIsCI = prevCI
53-
process.env['SCRIPTS_PRE-COMMIT'] = prevPreCommit
53+
process.env.SCRIPTS_PRE_COMMIT = prevPreCommit
5454
jest.resetModules()
5555
}
5656
},
@@ -59,7 +59,7 @@ cases(
5959
'does not watch on CI': {
6060
ci: true,
6161
},
62-
'does not watch on SCRIPTS_PRE-COMMIT': {
62+
'does not watch on SCRIPTS_PRE_COMMIT': {
6363
preCommit: 'true',
6464
},
6565
'does not watch with --no-watch': {

src/scripts/__tests__/validate.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cases(
1010
const {sync: crossSpawnSyncMock} = require('cross-spawn')
1111
const originalExit = process.exit
1212
process.exit = jest.fn()
13-
process.env['SCRIPTS_PRE-COMMIT'] = 'false'
13+
process.env.SCRIPTS_PRE_COMMIT = 'false'
1414
const teardown = setup()
1515

1616
try {
@@ -50,10 +50,10 @@ cases(
5050
},
5151
[`doesn't use test or lint if it's in pre-commit`]: {
5252
setup: withDefaultSetup(() => {
53-
const previousVal = process.env['SCRIPTS_PRE-COMMIT']
54-
process.env['SCRIPTS_PRE-COMMIT'] = 'true'
53+
const previousVal = process.env.SCRIPTS_PRE_COMMIT
54+
process.env.SCRIPTS_PRE_COMMIT = 'true'
5555
return function teardown() {
56-
process.env['SCRIPTS_PRE-COMMIT'] = previousVal
56+
process.env.SCRIPTS_PRE_COMMIT = previousVal
5757
}
5858
}),
5959
},

src/scripts/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const args = process.argv.slice(2)
88

99
const watch =
1010
!isCI &&
11-
!parseEnv('SCRIPTS_PRE-COMMIT', false) &&
11+
!parseEnv('SCRIPTS_PRE_COMMIT', false) &&
1212
!args.includes('--no-watch') &&
1313
!args.includes('--coverage') &&
1414
!args.includes('--updateSnapshot')

src/scripts/validate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
// pre-commit runs linting and tests on the relevant files
1010
// so those scripts don't need to be run if we're running
1111
// this in the context of a pre-commit hook.
12-
const preCommit = parseEnv('SCRIPTS_PRE-COMMIT', false)
12+
const preCommit = parseEnv('SCRIPTS_PRE_COMMIT', false)
1313

1414
const validateScripts = process.argv[2]
1515

0 commit comments

Comments
 (0)