Install: avoid race conditions when creating directories (#1358)

This commit is contained in:
ajhool
2018-08-29 04:20:26 -04:00
committed by Lovell Fuller
parent 5bed3a7d52
commit bf3254cb16
5 changed files with 50 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ const fs = require('fs');
const path = require('path');
const copyFileSync = require('fs-copy-file-sync');
const libvips = require('../lib/libvips');
const npmLog = require('npmlog');
if (process.platform === 'win32') {
@@ -11,8 +12,8 @@ if (process.platform === 'win32') {
const buildReleaseDir = path.join(buildDir, 'Release');
npmLog.info('sharp', `Creating ${buildReleaseDir}`);
try {
fs.mkdirSync(buildDir);
fs.mkdirSync(buildReleaseDir);
libvips.mkdirSync(buildDir);
libvips.mkdirSync(buildReleaseDir);
} catch (err) {}
const vendorLibDir = path.join(__dirname, '..', 'vendor', 'lib');
npmLog.info('sharp', `Copying DLLs from ${vendorLibDir} to ${buildReleaseDir}`);

View File

@@ -20,9 +20,7 @@ const distBaseUrl = process.env.SHARP_DIST_BASE_URL || `https://github.com/lovel
const extractTarball = function (tarPath) {
const vendorPath = path.join(__dirname, '..', 'vendor');
if (!fs.existsSync(vendorPath)) {
fs.mkdirSync(vendorPath);
}
libvips.mkdirSync(vendorPath);
tar
.extract({
file: tarPath,