UNPKG

1.04 kBJavaScriptView Raw
1'use strict';
2
3const fs = require('fs');
4const path = require('path');
5
6const libvips = require('../lib/libvips');
7const npmLog = require('npmlog');
8
9const platform = process.env.npm_config_platform || process.platform;
10if (platform === 'win32') {
11 const buildDir = path.join(__dirname, '..', 'build');
12 const buildReleaseDir = path.join(buildDir, 'Release');
13 npmLog.info('sharp', `Creating ${buildReleaseDir}`);
14 try {
15 libvips.mkdirSync(buildDir);
16 libvips.mkdirSync(buildReleaseDir);
17 } catch (err) {}
18 const vendorLibDir = path.join(__dirname, '..', 'vendor', 'lib');
19 npmLog.info('sharp', `Copying DLLs from ${vendorLibDir} to ${buildReleaseDir}`);
20 try {
21 fs
22 .readdirSync(vendorLibDir)
23 .filter(function (filename) {
24 return /\.dll$/.test(filename);
25 })
26 .forEach(function (filename) {
27 fs.copyFileSync(
28 path.join(vendorLibDir, filename),
29 path.join(buildReleaseDir, filename)
30 );
31 });
32 } catch (err) {
33 npmLog.error('sharp', err.message);
34 }
35}