Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Fixes handling of empty string entries for bin in package.json

[#6515](https://github.com/yarnpkg/yarn/pull/6515) - [**Ryan Burrows**](https://github.com/rhburrows)

- Adds support for basic auth for registries with paths, such as artifactory

[#5322](https://github.com/yarnpkg/yarn/pull/5322) - [**Karolis Narkevicius**](https://twitter.com/KidkArolis)
Expand Down
6 changes: 6 additions & 0 deletions __tests__/__snapshots__/normalize-manifest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ Array [
]
`;

exports[`empty bin string: empty bin string 1`] = `
Array [
"foo: No license field",
]
`;

exports[`engines array: engines array 1`] = `
Array [
"No license field",
Expand Down
9 changes: 9 additions & 0 deletions __tests__/commands/install/bin-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ test('can use link protocol to install a package that would not be found via nod
});
});

test('empty bin string does not create a link', (): Promise<void> => {
return runInstall({binLinks: true}, 'install-empty-bin', async config => {
const binScripts = await fs.walk(path.join(config.cwd, 'node_modules', '.bin'));
expect(binScripts).toHaveLength(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have length 2 on Windows, as two files are created per binary on Windows (one Bash script for linux-like environments like Cygwin, and one .cmd Batch script). This is why the appveyor tests are failing.


expect(await linkAt(config, 'node_modules', '.bin', 'depB')).toEqual('../depB/depb.js');
});
});

describe('with nohoist', () => {
// address https://github.com/yarnpkg/yarn/issues/5487
test('nohoist bin should be linked to its own local module', (): Promise<void> => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "depA",
"version": "0.0.0",
"bin": ""
}
2 changes: 2 additions & 0 deletions __tests__/fixtures/install/install-empty-bin/depB/depb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
console.log('depB');
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "depB",
"version": "0.0.0",
"bin": "./depb.js"
}
9 changes: 9 additions & 0 deletions __tests__/fixtures/install/install-empty-bin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "test",
"version": "0.0.0",
"bin": "",
"dependencies": {
"depA": "file:depA",
"depB": "file:depB"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "foo",
"bin": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "foo",
"version": "",
"bin": ""
}
2 changes: 1 addition & 1 deletion src/util/normalize-manifest/fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default (async function(
// if the `bin` field is as string then expand it to an object with a single property
// based on the original `bin` field and `name field`
// { name: "foo", bin: "cli.js" } -> { name: "foo", bin: { foo: "cli.js" } }
if (typeof info.name === 'string' && typeof info.bin === 'string') {
if (typeof info.name === 'string' && typeof info.bin === 'string' && info.bin.length > 0) {
// Remove scoped package name for consistency with NPM's bin field fixing behaviour
const name = info.name.replace(/^@[^\/]+\//, '');
info.bin = {[name]: info.bin};
Expand Down