Skip to content

Commit

Permalink
Anchor package.json files to the package’s root (#6562)
Browse files Browse the repository at this point in the history
* Anchor files to the package’s root

npm pack bases paths from the `files` array from the package’s
root. This updates yarn pack to behave in the same way.

* Update CHANGELOG.md
  • Loading branch information
tusbar authored and arcanis committed Oct 22, 2018
1 parent 04b23e4 commit 5876b30
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Expand Up @@ -4,15 +4,15 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Run the engines check before showing the UI for `upgrade-interactive`
- Ensures the engine check is ran before showing the UI for `upgrade-interactive`

[#6536](https://github.com/yarnpkg/yarn/pull/6536) - [**Orta Therox**](https://github.com/orta)

- Restore Node v4 support by downgrading `cli-table3`
- Restores Node v4 support by downgrading `cli-table3`

[#6535](https://github.com/yarnpkg/yarn/pull/6535) - [**Mark Stacey**](https://github.com/Gudahtt)

- Prevent infinite loop when parsing corrupted lockfile with unterminated string
- Prevents infinite loop when parsing corrupted lockfiles with unterminated strings

[#4965](https://github.com/yarnpkg/yarn/pull/4965) - [**Ryan Hendrickson**](https://github.com/rhendric)

Expand All @@ -32,6 +32,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

[#5322](https://github.com/yarnpkg/yarn/pull/5322) - [**Karolis Narkevicius**](https://twitter.com/KidkArolis)

- Fixes how the `files` property is interpreted to bring it in line with npm

[#6562](https://github.com/yarnpkg/yarn/pull/6562) - [**Bertrand Marron**](https://github.com/tusbar)

## 1.12.0

- Adds initial support for PnP on Windows
Expand Down
12 changes: 12 additions & 0 deletions __tests__/commands/pack.js
Expand Up @@ -67,6 +67,18 @@ test.concurrent('pack should include all files listed in the files array', (): P
});
});

test.concurrent('pack should include files based from the package’s root', (): Promise<void> => {
return runPack([], {}, 'files-include-from-root', async (config): Promise<void> => {
const {cwd} = config;
const files = await getFilesFromArchive(
path.join(cwd, 'files-include-from-root-v1.0.0.tgz'),
path.join(cwd, 'files-include-from-root-v1.0.0'),
);
expect(files.indexOf('index.js')).toBeGreaterThanOrEqual(0);
expect(files.indexOf('sub/index.js')).toEqual(-1);
});
});

test.concurrent('pack should included globbed files', (): Promise<void> => {
return runPack([], {}, 'files-glob', async (config): Promise<void> => {
const {cwd} = config;
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/pack/files-include-from-root/index.js
@@ -0,0 +1 @@
console.log('included');
6 changes: 6 additions & 0 deletions __tests__/fixtures/pack/files-include-from-root/package.json
@@ -0,0 +1,6 @@
{
"name": "files-include-from-root",
"version": "1.0.0",
"license": "MIT",
"files": ["index.js"]
}
@@ -0,0 +1 @@
console.log('not included');
2 changes: 1 addition & 1 deletion src/cli/commands/pack.js
Expand Up @@ -88,7 +88,7 @@ export async function packTarball(
onlyFiles.map((filename: string): string => `!${filename}`),
onlyFiles.map((filename: string): string => `!${path.join(filename, '**')}`),
);
const regexes = ignoreLinesToRegex(lines, '.');
const regexes = ignoreLinesToRegex(lines, './');
filters = filters.concat(regexes);
}

Expand Down

0 comments on commit 5876b30

Please sign in to comment.