-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bin): Implement an optional parameter support to
yarn bin
(#5739)
* feat(bin): Implement an optional parameter support to `yarn bin` This allows to get the path to a binary without making assumptions regarding the layout of the `node_modules` folder. BREAKING CHANGE: n/a n/a * Adds `yarn bin` tests * Update en.js * Update bin.js * Update bin.js * Fixes the tests
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* @flow */ | ||
|
||
import {run as buildRun, runInstall} from './_helpers.js'; | ||
import {BufferReporter} from '../../src/reporters/index.js'; | ||
import {run} from '../../src/cli/commands/bin.js'; | ||
|
||
const path = require('path'); | ||
|
||
const fixturesLoc = path.join(__dirname, '..', 'fixtures', 'bin'); | ||
const runBin = buildRun.bind(null, BufferReporter, fixturesLoc, (args, flags, config, reporter): Promise<void> => { | ||
return run(config, reporter, flags, args); | ||
}); | ||
|
||
test('running bin without arguments should return the folder where the binaries are stored', (): Promise<void> => { | ||
return runBin([], {}, '../install/install-production-bin', (config, reporter): ?Promise<void> => { | ||
expect(reporter.getBufferText()).toMatch(/[\\\/]node_modules[\\\/]\.bin[\\\/]?$/); | ||
}); | ||
}); | ||
|
||
test('running bin with a binary name as the argument should return its full path', (): Promise<void> => { | ||
return runInstall({binLinks: true}, 'install-production-bin', async (config): ?Promise<void> => { | ||
const reporter = new BufferReporter(); | ||
await run(config, reporter, {}, ['rimraf']); | ||
expect(reporter.getBufferText()).toMatch(/[\\\/]node_modules[\\\/]\.bin[\\\/]rimraf$/); | ||
}); | ||
}); |
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