Skip to content

Commit

Permalink
Fixes to PR 6007 (#6207)
Browse files Browse the repository at this point in the history
* fix: ensure enableDefaultRc defaults to true unless exlicitly set to false via --no-default-rc

* fix: ensure enableDefaultRc and extraneousYarnrcFiles are passed to config.init(...)

* add: added test for yarn global add for module using a scoped registry
  • Loading branch information
Clinton Wood authored and Maël Nison committed Aug 3, 2018
1 parent 456571b commit 6f5764b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
9 changes: 9 additions & 0 deletions __tests__/commands/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ test.concurrent('add', async (): Promise<void> => {
});
});

test.concurrent('add (with scoped registry)', (): Promise<void> => {
const flags = {enableDefaultRc: true};
return runGlobal(['add', '@test-scope/scoped-module'], flags, 'add-with-scoped-registry', async config => {
expect(await fs.exists(path.join(config.globalFolder, 'node_modules', '@test-scope', 'scoped-module'))).toEqual(
true,
);
});
});

test.concurrent('remove', async (): Promise<void> => {
const tmpGlobalFolder = await createTempGlobalFolder();
const tmpPrefixFolder = await createTempPrefixFolder();
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/global/add-with-scoped-registry/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@test-scope:registry" "http://test-scope-registry.com"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
HTTP/1.1 200 OK
X-Powered-By: verdaccio/3.5.1
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
ETag: "44b57ba5bc86dbe39ef3e60f5112a6ec"
Content-Length: 754
Vary: Accept-Encoding
X-Status-Cat: http://flic.kr/p/aVuVsF
Date: Fri, 03 Aug 2018 06:37:42 GMT
Connection: keep-alive

{
"name": "@test-scope/scoped-module",
"versions": {
"0.0.1": {
"name": "@test-scope/scoped-module",
"version": "0.0.1",
"description": "Scoped Module for Yarn tests",
"main": "index.js",
"license": "MIT",
"_id": "@test-scope/[email protected]",
"dist": {
"shasum": "0d2cf8db4b0fca4f50a0597e9a377cb1e6c48a93",
"tarball": "http://test-scope-registry.com/@test-scope%2fscoped-module/-/scoped-module-0.0.1.tgz"
}
}
},
"time": {
"modified": "2018-08-03T06:33:38.743Z",
"created": "2018-08-03T06:33:38.743Z",
"0.0.1": "2018-08-03T06:33:38.743Z"
},
"dist-tags": {
"latest": "0.0.1"
},
"_rev": "6-7cc396d8f7359a4d",
"readme": "",
"_attachments": {}
}
Binary file not shown.
2 changes: 2 additions & 0 deletions src/cli/commands/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ async function updateCwd(config: Config): Promise<void> {
globalFolder: config.globalFolder,
cacheFolder: config._cacheRootFolder,
linkFolder: config.linkFolder,
enableDefaultRc: config.enableDefaultRc,
extraneousYarnrcFiles: config.extraneousYarnrcFiles,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export default class Config {

this.commandName = opts.commandName || '';

this.enableDefaultRc = !!opts.enableDefaultRc;
this.enableDefaultRc = opts.enableDefaultRc !== false;
this.extraneousYarnrcFiles = opts.extraneousYarnrcFiles || [];

this.preferOffline = !!opts.preferOffline;
Expand Down

0 comments on commit 6f5764b

Please sign in to comment.