-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for yarn installations #560
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
a68825d
feat: add support for yarn installations
SimenB 6e901eb
chore: install yarn on Travis CI
SimenB 2714b8a
PR feedback
SimenB 126ce60
explicitly add yarn to `$PATH`
SimenB 6a7013e
fix spawning of yarn process
SimenB 8904db1
add tests
SimenB c5dbdaa
skip failing tests
SimenB 9ced83d
Update lib/package-manager/test.js
targos 5cb839f
Revert "skip failing tests"
SimenB 190877f
remove invalid test for yarn
SimenB 938fec5
install yarn from npm
SimenB 9352ad6
extract package manager finder to separate module
SimenB 84c73cf
don't install yarn in .travis.yml
SimenB 3becd4d
name function [skip ci]
SimenB b6f99c1
fix find when bin is not in PATH
targos 61f3b3d
run custom test script and try to add yarn to path
SimenB fb3ea5a
remove custom test script
SimenB ede6a95
fix tests
SimenB 99df018
remove uknown flag from yarn call
SimenB 4e4cfa6
stringify buffers in test
SimenB 6829ba8
tweak assertion
SimenB 013b093
chore: rename file
SimenB 8f7795b
rename exported function
SimenB 261d246
simplify calling pkg manager install and test
SimenB 9bb22dc
cache package manager binary lookup
SimenB 792e673
fix failing test
SimenB 669492e
PR feedback
SimenB 04964a3
lint
SimenB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const which = require('which'); | ||
const npmWhich = require('npm-which')(__dirname); | ||
|
||
const windows = (process.platform === 'win32'); | ||
|
||
module.exports = function getExecutable(binaryName, next) { | ||
if (binaryName === 'yarn') { | ||
// Use `npm-which` for yarn to get the locally version | ||
npmWhich(binaryName, next); | ||
|
||
return; | ||
} | ||
|
||
which(binaryName, (err, packageManagerBin) => { | ||
if (err) { | ||
next(err); | ||
return; | ||
} | ||
|
||
if (windows) { | ||
packageManagerBin = path.join(path.dirname(packageManagerBin), | ||
'node_modules', 'npm', 'bin', 'npm-cli.js'); | ||
} | ||
|
||
next(null, packageManagerBin); | ||
}); | ||
}; |
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,43 @@ | ||
'use strict'; | ||
|
||
SimenB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const async = require('async'); | ||
|
||
const install = require('./install'); | ||
const test = require('./test'); | ||
const getExecutable = require('./get-executable'); | ||
|
||
function pkgInstall(context, next) { | ||
if (context.options.yarn || context.module.useYarn) { | ||
install('yarn', context, next); | ||
} else { | ||
install('npm', context, next); | ||
} | ||
} | ||
|
||
function pkgTest(context, next) { | ||
if (context.options.yarn || context.module.useYarn) { | ||
test('yarn', context, next); | ||
} else { | ||
test('npm', context, next); | ||
} | ||
} | ||
|
||
function getPackageManagers(next) { | ||
async.parallel([ | ||
getExecutable.bind(null, 'npm'), | ||
getExecutable.bind(null, 'yarn') | ||
], (err, res) => { | ||
if (err) { | ||
next(err); | ||
return; | ||
} | ||
|
||
next(null, { npm: res[0], yarn: res[1] }); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
install: pkgInstall, | ||
test: pkgTest, | ||
getPackageManagers: getPackageManagers | ||
}; |
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 |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
"mkdirp": "^0.5.1", | ||
"normalize-git-url": "^3.0.2", | ||
"npm-package-arg": "^6.1.0", | ||
"npm-which": "^3.0.1", | ||
"osenv": "^0.1.5", | ||
"read-package-json": "^2.0.13", | ||
"request": "^2.88.0", | ||
|
@@ -55,7 +56,8 @@ | |
"winston": "^2.4.4", | ||
"xml-sanitizer": "^1.1.6", | ||
"xmlbuilder": "^10.1.1", | ||
"yargs": "^12.0.2" | ||
"yargs": "^12.0.2", | ||
"yarn": "^1.12.3" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dependency on purpose as mentioned. See #560 (comment) |
||
}, | ||
"devDependencies": { | ||
"eslint": "^5.7.0", | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason we can't use npmWhich for both
npm
andyarn
?. If that's the case and it is pass through could we not remove this script altogether?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm-which
is just for binaries installed innode_modules
. Not sure if it finds globally installed stuff?Could potentially add
npm
as a dep as well, then it won't rely on any globals beyond node. Maybe not worth it?IDK about the windows thing below. Would that just work ™️? I don't have access to a windows machine to test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it just how it is for now, this makes sense. I was more confused by the usage above