diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js b/packages/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js index 758c75a5c15c..01cea9487c8f 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/pack.test.js @@ -118,6 +118,24 @@ describe(`Commands`, () => { }), ); + test( + `it should ignore root .gitignore files when using the 'files' field`, + makeTemporaryEnv({ + files: [ + `lib`, + ], + }, async ({path, run, source}) => { + await fsUtils.writeFile(`${path}/.gitignore`, `lib`); + + await run(`install`); + + await fsUtils.writeFile(`${path}/lib/foo.js`); + + const {stdout} = await run(`pack`, `--dry-run`); + await expect(stdout).toMatch(/lib\/foo\.js/); + }), + ); + test( `it shouldn't add the cache to the package files`, makeTemporaryEnv({}, async ({path, run, source}) => { diff --git a/packages/plugin-pack/package.json b/packages/plugin-pack/package.json index e7d0f87c0fb9..c33176ce6d78 100644 --- a/packages/plugin-pack/package.json +++ b/packages/plugin-pack/package.json @@ -13,6 +13,10 @@ "tar-stream": "^2.0.1" }, "version": "2.0.0-rc.4", + "nextVersion": { + "semver": "2.0.0-rc.5", + "nonce": "3390682135047771" + }, "repository": { "type": "git", "url": "ssh://git@github.com/yarnpkg/berry.git" diff --git a/packages/plugin-pack/sources/packUtils.ts b/packages/plugin-pack/sources/packUtils.ts index 1eb99ce5fd7d..7b6e19531a88 100644 --- a/packages/plugin-pack/sources/packUtils.ts +++ b/packages/plugin-pack/sources/packUtils.ts @@ -205,21 +205,23 @@ export async function genPackList(workspace: Workspace) { else if (workspace.manifest.module) ignoreList.accept.push(ppath.resolve(PortablePath.root, workspace.manifest.module)); - if (workspace.manifest.files !== null) { + const hasExplicitFileList = workspace.manifest.files !== null; + if (hasExplicitFileList) { ignoreList.reject.push(`/*`); - for (const pattern of workspace.manifest.files) { + for (const pattern of workspace.manifest.files!) { addIgnorePattern(ignoreList.accept, pattern, {cwd: PortablePath.root}); } } return await walk(workspace.cwd, { + hasExplicitFileList, globalList, ignoreList, }); } -async function walk(initialCwd: PortablePath, {globalList, ignoreList}: {globalList: IgnoreList, ignoreList: IgnoreList}) { +async function walk(initialCwd: PortablePath, {hasExplicitFileList, globalList, ignoreList}: {hasExplicitFileList: boolean, globalList: IgnoreList, ignoreList: IgnoreList}) { const list: PortablePath[] = []; const cwdFs = new JailFS(initialCwd); @@ -238,9 +240,11 @@ async function walk(initialCwd: PortablePath, {globalList, ignoreList}: {globalL let hasGitIgnore = false; let hasNpmIgnore = false; - for (const entry of entries) { - hasGitIgnore = hasGitIgnore || entry === `.gitignore`; - hasNpmIgnore = hasNpmIgnore || entry === `.npmignore`; + if (!hasExplicitFileList || cwd !== PortablePath.root) { + for (const entry of entries) { + hasGitIgnore = hasGitIgnore || entry === `.gitignore`; + hasNpmIgnore = hasNpmIgnore || entry === `.npmignore`; + } } const localIgnoreList = hasNpmIgnore diff --git a/packages/yarnpkg-cli/package.json b/packages/yarnpkg-cli/package.json index da3b40fdcc69..9c08c8c07d21 100644 --- a/packages/yarnpkg-cli/package.json +++ b/packages/yarnpkg-cli/package.json @@ -1,6 +1,10 @@ { "name": "@yarnpkg/cli", "version": "2.0.0-rc.9", + "nextVersion": { + "semver": "2.0.0-rc.10", + "nonce": "3585046797413477" + }, "main": "./sources/index.ts", "dependencies": { "@yarnpkg/core": "workspace:2.0.0-rc.9",