diff --git a/__tests__/commands/install/lockfiles.js b/__tests__/commands/install/lockfiles.js index 184464313a..638636eb86 100644 --- a/__tests__/commands/install/lockfiles.js +++ b/__tests__/commands/install/lockfiles.js @@ -15,6 +15,12 @@ const fsNode = require('fs'); const path = require('path'); const os = require('os'); +test.concurrent('does fetch files from the local filesystem', (): Promise => { + return runInstall({}, 'install-should-fetch-local-tarballs', (config): Promise => { + return Promise.resolve(); + }); +}); + test.concurrent("doesn't write new lockfile if existing one satisfied", (): Promise => { return runInstall({}, 'install-dont-write-lockfile-if-satisfied', async (config): Promise => { const lockfile = await fs.readFile(path.join(config.cwd, 'yarn.lock')); diff --git a/__tests__/fixtures/install/install-should-fetch-local-tarballs/@fakescope-fake-dependency-1.0.1.tgz b/__tests__/fixtures/install/install-should-fetch-local-tarballs/@fakescope-fake-dependency-1.0.1.tgz new file mode 100644 index 0000000000..29e48dd0cd Binary files /dev/null and b/__tests__/fixtures/install/install-should-fetch-local-tarballs/@fakescope-fake-dependency-1.0.1.tgz differ diff --git a/__tests__/fixtures/install/install-should-fetch-local-tarballs/fake-dependency-1.0.1.tgz b/__tests__/fixtures/install/install-should-fetch-local-tarballs/fake-dependency-1.0.1.tgz new file mode 100644 index 0000000000..a3d3363603 Binary files /dev/null and b/__tests__/fixtures/install/install-should-fetch-local-tarballs/fake-dependency-1.0.1.tgz differ diff --git a/__tests__/fixtures/install/install-should-fetch-local-tarballs/package.json b/__tests__/fixtures/install/install-should-fetch-local-tarballs/package.json new file mode 100644 index 0000000000..7c8821b1ba --- /dev/null +++ b/__tests__/fixtures/install/install-should-fetch-local-tarballs/package.json @@ -0,0 +1,6 @@ +{ + "license": "MIT", + "dependencies": { + "fake-dependency": "./fake-dependency-1.0.1.tgz" + } +} diff --git a/src/fetchers/tarball-fetcher.js b/src/fetchers/tarball-fetcher.js index 95c931f687..face3ddbae 100644 --- a/src/fetchers/tarball-fetcher.js +++ b/src/fetchers/tarball-fetcher.js @@ -106,7 +106,7 @@ export default class TarballFetcher extends BaseFetcher { const tarballMirrorPath = this.getTarballMirrorPath(); const tarballCachePath = this.getTarballCachePath(); - const tarballPath = override || tarballMirrorPath || tarballCachePath; + const tarballPath = path.resolve(this.config.cwd, override || tarballMirrorPath || tarballCachePath); if (!tarballPath || !await fsUtil.exists(tarballPath)) { throw new MessageError(this.config.reporter.lang('tarballNotInNetworkOrCache', this.reference, tarballPath)); @@ -178,6 +178,12 @@ export default class TarballFetcher extends BaseFetcher { } async _fetch(): Promise { + const urlParse = url.parse(this.reference); + + if (urlParse.protocol === null && urlParse.pathname.match(/^\.\.?[\/\\]/)) { + return await this.fetchFromLocal(this.reference); + } + if (await this.getLocalAvailabilityStatus()) { return await this.fetchFromLocal(); } else {