Skip to content

Commit

Permalink
Merge pull request #152 from realityking/make-dir
Browse files Browse the repository at this point in the history
Replace mkdirp with make-dir
  • Loading branch information
sergcen committed Nov 4, 2020
2 parents 128d154 + 85e576d commit c015718
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
26 changes: 17 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -23,9 +23,9 @@
"node": ">=10"
},
"dependencies": {
"make-dir": "3.1.0",
"mime": "2.3.1",
"minimatch": "3.0.4",
"mkdirp": "0.5.0",
"xxhashjs": "0.2.1"
},
"devDependencies": {
Expand Down
16 changes: 2 additions & 14 deletions src/type/copy.js
Expand Up @@ -2,7 +2,7 @@

const path = require('path');
const fs = require('fs');
const mkdirp = require('mkdirp');
const makeDir = require('make-dir');

const calcHash = require('../lib/hash');
const paths = require('../lib/paths');
Expand All @@ -17,18 +17,6 @@ const getHashName = (file, options) =>
+ calcHash(file.contents, options)
+ path.extname(file.path);

const createDirAsync = (dirPath) => {
return new Promise((resolve, reject) => {
mkdirp(dirPath, (err) => {
if (err) {
reject(err);
}

resolve();
});
});
};

const writeFileAsync = (file, dest) => {
return new Promise((resolve, reject) => {
fs.writeFile(dest, file.contents, { flag: 'wx' }, (err) => {
Expand Down Expand Up @@ -79,7 +67,7 @@ module.exports = function processCopy(asset, dir, options, decl, warn, result, a
const newAssetPath = path.join(newAssetBaseDir, assetRelativePath);
const newRelativeAssetPath = normalize(path.relative(targetDir, newAssetPath));

return createDirAsync(path.dirname(newAssetPath))
return makeDir(path.dirname(newAssetPath))
.then(() => writeFileAsync(file, newAssetPath))
.then(() => {
addDependency(file.path);
Expand Down

0 comments on commit c015718

Please sign in to comment.