Skip to content

Commit

Permalink
Fixes offline resolution for absolute Windows paths (#3319)
Browse files Browse the repository at this point in the history
* Fixes offline resolution for absolute Windows paths

* lint fix

* Update tarball-fetcher.js

* Update lockfiles.js

* Update lockfiles.js
  • Loading branch information
arcanis authored and bestander committed May 4, 2017
1 parent 1912235 commit 8be7dc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion __tests__/commands/install/lockfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ test('does fetch files from the local filesystem', (): Promise<void> => {
return runInstall({}, 'install-should-fetch-local-tarballs', (config): Promise<void> => {
return Promise.resolve();
}, async (cwd) => {
await fs.writeFile(`${cwd}/package.json`, (await fs.readFile(`${cwd}/package.json`)).replace(/%%CWD%%/g, cwd.replace(/\\/g, `/`)));
let packageJson = await fs.readFile(`${cwd}/package.json`);
packageJson = packageJson.replace(/%%CWD%%/g, cwd.replace(/\\/g, `/`));
await fs.writeFile(`${cwd}/package.json`, packageJson);
});
});

Expand Down
8 changes: 7 additions & 1 deletion src/fetchers/tarball-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ export default class TarballFetcher extends BaseFetcher {
async _fetch(): Promise<FetchedOverride> {
const urlParse = url.parse(this.reference);

if (urlParse.protocol === null && urlParse.pathname.match(/^(?=(?:\.{1,2}|[a-z]:)?[\\\/])/i)) {
const isFilePath = urlParse.protocol
? urlParse.protocol.match(/^[a-z]:$/i)
: urlParse.pathname
? urlParse.pathname.match(/^(?:\.{1,2})?[\\\/]/)
: false;

if (isFilePath) {
return await this.fetchFromLocal(this.reference);
}

Expand Down

0 comments on commit 8be7dc3

Please sign in to comment.