Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions __tests__/commands/install/lockfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
return runInstall({}, 'install-should-fetch-local-tarballs', (config): Promise<void> => {
return Promise.resolve();
});
});

test.concurrent("doesn't write new lockfile if existing one satisfied", (): Promise<void> => {
return runInstall({}, 'install-dont-write-lockfile-if-satisfied', async (config): Promise<void> => {
const lockfile = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"license": "MIT",
"dependencies": {
"fake-dependency": "./fake-dependency-1.0.1.tgz"
}
}
8 changes: 7 additions & 1 deletion src/fetchers/tarball-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -178,6 +178,12 @@ export default class TarballFetcher extends BaseFetcher {
}

async _fetch(): Promise<FetchedOverride> {
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 {
Expand Down
4 changes: 3 additions & 1 deletion src/util/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ async function buildActionsForCopy(
destStat = await lstat(dest);
} catch (e) {
// proceed if destination doesn't exist, otherwise error
if (e.code !== 'ENOENT') throw e;
if (e.code !== 'ENOENT') {
throw e;
}
}

// if destination exists
Expand Down