Skip to content

Commit 5876b30

Browse files
tusbararcanis
authored andcommitted
Anchor package.json files to the package’s root (#6562)
* 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
1 parent 04b23e4 commit 5876b30

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa
44

55
## Master
66

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

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

11-
- Restore Node v4 support by downgrading `cli-table3`
11+
- Restores Node v4 support by downgrading `cli-table3`
1212

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

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

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

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

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

35+
- Fixes how the `files` property is interpreted to bring it in line with npm
36+
37+
[#6562](https://github.com/yarnpkg/yarn/pull/6562) - [**Bertrand Marron**](https://github.com/tusbar)
38+
3539
## 1.12.0
3640

3741
- Adds initial support for PnP on Windows

__tests__/commands/pack.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ test.concurrent('pack should include all files listed in the files array', (): P
6767
});
6868
});
6969

70+
test.concurrent('pack should include files based from the package’s root', (): Promise<void> => {
71+
return runPack([], {}, 'files-include-from-root', async (config): Promise<void> => {
72+
const {cwd} = config;
73+
const files = await getFilesFromArchive(
74+
path.join(cwd, 'files-include-from-root-v1.0.0.tgz'),
75+
path.join(cwd, 'files-include-from-root-v1.0.0'),
76+
);
77+
expect(files.indexOf('index.js')).toBeGreaterThanOrEqual(0);
78+
expect(files.indexOf('sub/index.js')).toEqual(-1);
79+
});
80+
});
81+
7082
test.concurrent('pack should included globbed files', (): Promise<void> => {
7183
return runPack([], {}, 'files-glob', async (config): Promise<void> => {
7284
const {cwd} = config;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('included');
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "files-include-from-root",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"files": ["index.js"]
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('not included');

src/cli/commands/pack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export async function packTarball(
8888
onlyFiles.map((filename: string): string => `!${filename}`),
8989
onlyFiles.map((filename: string): string => `!${path.join(filename, '**')}`),
9090
);
91-
const regexes = ignoreLinesToRegex(lines, '.');
91+
const regexes = ignoreLinesToRegex(lines, './');
9292
filters = filters.concat(regexes);
9393
}
9494

0 commit comments

Comments
 (0)