Skip to content

Commit

Permalink
fix(Standalone): Ensure pkg bug workaround is applied on WIndows
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed May 11, 2020
1 parent 08dc745 commit 8bc6d54
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/utils/standalone-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const path = require('path');
const originalCopyFile = fs.copyFile;
const originalCopyFileSync = fs.copyFileSync;

const isBundled = RegExp.prototype.test.bind(/^(?:\/snapshot\/|[A-Z]+:\\snapshot\\)/);

fs.copyFile = function copyFile(src, dest, flags, callback) {
if (!path.resolve(src).startsWith('/snapshot/')) {
if (!isBundled(path.resolve(src))) {
originalCopyFile(src, dest, flags, callback);
return;
}
Expand Down Expand Up @@ -49,7 +51,7 @@ fs.copyFile = function copyFile(src, dest, flags, callback) {
};

fs.copyFileSync = function copyFileSync(src, dest, flags) {
if (!path.resolve(src).startsWith('/snapshot/')) {
if (!isBundled(path.resolve(src))) {
originalCopyFileSync(src, dest, flags);
return;
}
Expand Down

0 comments on commit 8bc6d54

Please sign in to comment.