dll-copy.js 1.0 KB

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