Skip to content
Permalink
Browse files

Update: Add support for "//" comments in package.json dependencies (#…

…3829)

**Summary**
Fixes #2484. Adds support for the `"//"` package in package.json, by deleting it before we resolve the dependencies.

**Test plan**

Adds a new integration test.
  • Loading branch information...
jseminck authored and BYK committed Jul 6, 2017
1 parent ad1a4f5 commit fc6fb656dea0917ac001a332fbc0f5afa5d0c043
@@ -471,6 +471,12 @@ test.concurrent('install should run install scripts in the order of dependencies
});
});

test.concurrent('install with comments in manifest', (): Promise<void> => {
return runInstall({noLockfile: true}, 'install-with-comments', async config => {
expect(await fs.readFile(path.join(config.cwd, 'node_modules', 'foo', 'index.js'))).toEqual('foobar;\n');
});
});

test.concurrent('run install scripts in the order when one dependency does not have install script', (): Promise<
void,
> => {
@@ -0,0 +1,5 @@
{
"name": "bar",
"version": "0.0.0",
"main": "index.js"
}
@@ -0,0 +1,10 @@
{
"dependencies": {
"//": [
"This is a",
"multiline",
"comment"
],
"foo": "file:bar"
}
}
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"foo@file:bar":
version "0.0.0"
@@ -227,6 +227,13 @@ export class Install {

this.rootManifestRegistries.push(registry);
const projectManifestJson = await this.config.readJson(loc);

['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'].forEach(dependencyKey => {
if (projectManifestJson[dependencyKey]) {
delete projectManifestJson[dependencyKey]['//'];
}
});

await normalizeManifest(projectManifestJson, this.config.cwd, this.config, true);

Object.assign(this.resolutions, projectManifestJson.resolutions);

0 comments on commit fc6fb65

Please sign in to comment.
You can’t perform that action at this time.