Skip to content

Commit

Permalink
Add support for older node versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
deryni committed Jun 26, 2017
1 parent a7b4fd8 commit b06b140
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/writeFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import loaderUtils from 'loader-utils';
import path from 'path';

const fs = Promise.promisifyAll(require('fs')); // eslint-disable-line import/no-commonjs
const constants = Promise.promisifyAll(require('constants')); // eslint-disable-line import/no-commonjs

export default function writeFile(globalRef, pattern, file) {
const {info, debug, compilation, fileDependencies, written, copyUnmodified} = globalRef;
Expand Down Expand Up @@ -87,9 +88,12 @@ export default function writeFile(globalRef, pattern, file) {
written[file.absoluteFrom].copyPermissions = pattern.copyPermissions;
written[file.absoluteFrom].webpackTo = file.webpackTo;

perms |= stat.mode & fs.constants.S_IRWXU;
perms |= stat.mode & fs.constants.S_IRWXG;
perms |= stat.mode & fs.constants.S_IRWXO;
let constsfrom = fs.constants || constants;

perms |= stat.mode & constsfrom.S_IRWXU;
perms |= stat.mode & constsfrom.S_IRWXG;
perms |= stat.mode & constsfrom.S_IRWXO;

written[file.absoluteFrom].perms = perms;
}

Expand Down

0 comments on commit b06b140

Please sign in to comment.