Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent --check-files from crossing symlinks #3931

Merged
merged 5 commits into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions __tests__/commands/install/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ async function mockConstants(base: Config, mocks: Object, cb: (config: Config) =
beforeEach(request.__resetAuthedRequests);
afterEach(request.__resetAuthedRequests);

test.concurrent('packages installed through the link protocol should validate all peer dependencies', async () => {
await runInstall({checkFiles: true}, 'check-files-should-not-cross-symlinks', async (config): Promise<void> => {
expect(
JSON.parse(await fs.readFile(`${config.cwd}/node_modules/.yarn-integrity`)).files.map(file => {
return file.replace(/\\/g, '/');
}),
).toEqual(['some-missing-pkg', 'some-other-pkg', 'some-pkg/package.json']);
});
});

test.concurrent('installing a package with a renamed file should not delete it', async () => {
await runInstall({}, 'case-sensitivity', async (config, reporter): Promise<void> => {
const pkgJson = await fs.readJson(`${config.cwd}/package.json`);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"some-pkg": "file:./some-pkg/",
"some-other-pkg": "link:./some-other-pkg",
"some-missing-pkg": "link:./some-missing-pkg"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "some-other-pkg",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "some-pkg",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"some-missing-pkg@link:./some-missing-pkg":
version "0.0.0"
uid ""

"some-other-pkg@link:./some-other-pkg":
version "0.0.0"
uid ""

"some-pkg@file:./some-pkg/":
version "1.0.0"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"build-win-installer": "scripts\\build-windows-installer.bat",
"check-lockfile": "./scripts/check-lockfile.sh",
"lint": "eslint . && flow check",
"prettier": "eslint . --fix",
"prettier": "eslint src __tests__ --fix",
"release-branch": "./scripts/release-branch.sh",
"test": "yarn lint && yarn test-only",
"test-ci": "yarn build && yarn test-only",
Expand Down
2 changes: 1 addition & 1 deletion src/integrity-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class InstallationIntegrityChecker {
async function getFilePaths(rootDir: string, files: Array<string>, currentDir: string = rootDir): Promise<void> {
for (const file of await fs.readdir(currentDir)) {
const entry = path.join(currentDir, file);
const stat = await fs.stat(entry);
const stat = await fs.lstat(entry);
if (stat.isDirectory()) {
await getFilePaths(rootDir, files, entry);
} else {
Expand Down