-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: remove use of global npm cache and config
- Loading branch information
Showing
6 changed files
with
65 additions
and
24 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
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,24 @@ | ||
import { mkdir, writeFile } from 'fs/promises'; | ||
import { delimiter, join } from 'path'; | ||
import { getGlobalVariable } from '../utils/env'; | ||
import { npm } from '../utils/process'; | ||
|
||
/** | ||
* Configure npm to use a unique sandboxed environment. | ||
*/ | ||
export default async function () { | ||
const tempRoot: string = getGlobalVariable('tmp-root'); | ||
const npmGlobalModules = join(tempRoot, 'npm-global'); | ||
const npmCache = join(tempRoot, 'npm-cache'); | ||
const npmrc = join(tempRoot, '.npmrc'); | ||
|
||
// Re-enforce some of those configs in env vars | ||
process.env.NPM_CONFIG_USERCONFIG = npmrc; | ||
process.env.NPM_CONFIG_CACHE = npmCache; | ||
process.env.NPM_CONFIG_PREFIX = npmGlobalModules; | ||
|
||
// Ensure the custom npm global .bin is first on the PATH | ||
process.env.PATH = join(npmGlobalModules, 'bin') + delimiter + process.env.PATH; | ||
|
||
console.log(` Using "${npmGlobalModules}" as an isolated global npm cache.`); | ||
} |
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,13 @@ | ||
import { mkdir } from 'fs/promises'; | ||
import { join } from 'path'; | ||
import { getGlobalVariable } from '../utils/env'; | ||
|
||
export default async function () { | ||
const tempRoot: string = getGlobalVariable('tmp-root'); | ||
const projectsRoot = join(tempRoot, 'e2e-test'); | ||
|
||
await mkdir(projectsRoot); | ||
|
||
console.log(` Using "${projectsRoot}" as temporary directory for a new project.`); | ||
process.chdir(projectsRoot); | ||
} |
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