-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for yarn installations (#560)
- Loading branch information
Showing
21 changed files
with
479 additions
and
119 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
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'; | ||
|
||
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
Oops, something went wrong.