-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
windows working and fight node modules (#179)
* windows working * improve style and verbiage
- Loading branch information
Showing
9 changed files
with
63 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const path = require('path') | ||
const delineator = process.platform === 'win32' ? ';' : ':' | ||
test('quirks moves node_modules to back', () => { | ||
// key is that it has `node_modules` + path.sep | ||
const injectedStuff = `node_modules${path.sep}testOnly` | ||
// prepend to PATH | ||
process.env.PATH = injectedStuff + delineator + process.env.PATH | ||
const pathAsArray = process.env.PATH.split(delineator) | ||
// Yup it is prepended to front | ||
expect(pathAsArray[0]).toBe(injectedStuff) | ||
// require mutates PATH | ||
require('../../src/extensions/functions/quirksNodeModules') | ||
const newPathAsArray = process.env.PATH.split(delineator) | ||
// Not in the front | ||
expect(newPathAsArray[0]).not.toBe(injectedStuff) | ||
// still there though (moved to back) | ||
expect(process.env.PATH.includes(injectedStuff)).toBeTruthy() | ||
}) | ||
|
||
test('quirks does not move just any injected path to back', () => { | ||
const injectedStuff = `taco${path.sep}testOnly` | ||
// prepend to PATH | ||
process.env.PATH = injectedStuff + delineator + process.env.PATH | ||
const pathAsArray = process.env.PATH.split(delineator) | ||
// Yup it is prepended to front | ||
expect(pathAsArray[0]).toBe(injectedStuff) | ||
// require does not mutate PATH this time | ||
require('../../src/extensions/functions/quirksNodeModules') | ||
const newPathAsArray = process.env.PATH.split(delineator) | ||
// Not in the front | ||
expect(newPathAsArray[0]).toBe(injectedStuff) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { reject, contains, concat, difference } from 'ramda' | ||
const path = require('path') | ||
const delineator = process.platform === 'win32' ? ';' : ':' | ||
|
||
// Node mutates path by adding to the front, move that to the back if it exists | ||
const originalPath = process.env.PATH || '' | ||
const originalArray = originalPath.split(delineator) | ||
const cleanArray = reject(contains('node_modules' + path.sep), originalArray) | ||
process.env.PATH = concat(cleanArray, difference(originalArray, cleanArray)).join(delineator) |
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