Skip to content

Commit 00f6780

Browse files
arcanisbestander
authored andcommitted
Fix offline resolution (#3311)
1 parent 0b3c443 commit 00f6780

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

__tests__/commands/install/lockfiles.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ const fsNode = require('fs');
1515
const path = require('path');
1616
const os = require('os');
1717

18-
test.concurrent('does fetch files from the local filesystem', (): Promise<void> => {
18+
test('does fetch files from the local filesystem', (): Promise<void> => {
1919
return runInstall({}, 'install-should-fetch-local-tarballs', (config): Promise<void> => {
2020
return Promise.resolve();
21+
}, async (cwd) => {
22+
await fs.writeFile(`${cwd}/package.json`, (await fs.readFile(`${cwd}/package.json`)).replace(/%%CWD%%/g, cwd));
2123
});
2224
});
2325

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"license": "MIT",
33
"dependencies": {
4-
"fake-dependency": "./fake-dependency-1.0.1.tgz"
4+
"fake-dependency": "./fake-dependency-1.0.1.tgz",
5+
"@fakescope/fake-dependency": "%%CWD%%/fakescope-fake-dependency-1.0.1.tgz"
56
}
67
}

src/fetchers/tarball-fetcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default class TarballFetcher extends BaseFetcher {
180180
async _fetch(): Promise<FetchedOverride> {
181181
const urlParse = url.parse(this.reference);
182182

183-
if (urlParse.protocol === null && urlParse.pathname.match(/^\.\.?[\/\\]/)) {
183+
if (urlParse.protocol === null && urlParse.pathname.match(/^(?=(?:\.{1,2}|[a-z]:)?[\\\/])/i)) {
184184
return await this.fetchFromLocal(this.reference);
185185
}
186186

0 commit comments

Comments
 (0)