Skip to content

Commit

Permalink
Remove mkdirp and use fs.mkdirSync with the recursive option
Browse files Browse the repository at this point in the history
Requires Node.js >= 10.12.0
  • Loading branch information
XhmikosR committed Feb 23, 2021
1 parent e09fac0 commit 0adacc3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions bin/svg-sprite.js
Expand Up @@ -18,7 +18,6 @@
var _ = require('lodash'),
path = require('path'),
fs = require('fs'),
mkdirp = require('mkdirp'),
File = require('vinyl'),
yaml = require('js-yaml'),
glob = require('glob'),
Expand Down Expand Up @@ -130,7 +129,7 @@ function writeFiles(files) {
for (var key in files) {
if (_.isObject(files[key])) {
if (files[key].constructor === File) {
mkdirp.sync(path.dirname(files[key].path));
fs.mkdirSync(path.dirname(files[key].path), { recursive: true });
fs.writeFileSync(files[key].path, files[key].contents);
++written;
} else {
Expand Down
3 changes: 1 addition & 2 deletions example.js
@@ -1,6 +1,5 @@
var SVGSpriter = require('./lib/svg-sprite'),
path = require('path'),
mkdirp = require('mkdirp'),
fs = require('fs'),
glob = require('glob'),
cwd = path.join(__dirname, 'test', 'fixture', 'svg', 'single'),
Expand Down Expand Up @@ -42,7 +41,7 @@ addFixtureFiles(spriter, files).compile({
}
}, function (error, result, cssData) {
for (var type in result.css) {
mkdirp.sync(path.dirname(result.css[type].path));
fs.mkdirSync(path.dirname(result.css[type].path), { recursive: true });
fs.writeFileSync(result.css[type].path, result.css[type].contents);
}
})
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -13,7 +13,7 @@
},
"license": "MIT",
"engines": {
"node": ">=10"
"node": ">=10.12.0"
},
"main": "lib/svg-sprite.js",
"bin": {
Expand Down Expand Up @@ -46,7 +46,6 @@
"glob": "^7.1.6",
"js-yaml": "^3.14.1",
"lodash": "^4.17.21",
"mkdirp": "^0.5.5",
"mustache": "^4.1.0",
"phantomjs-prebuilt": "^2.1.16",
"prettysize": "^2.0.0",
Expand Down
7 changes: 3 additions & 4 deletions test/svg-sprite.js
Expand Up @@ -18,7 +18,6 @@ var util = require('util');
var svg2png = require('svg2png');
var should = require('should'),
path = require('path'),
mkdirp = require('mkdirp'),
rimraf = require('rimraf'),
glob = require('glob'),
File = require('vinyl'),
Expand Down Expand Up @@ -69,7 +68,7 @@ function writeFiles(files) {
for (var key in files) {
if (_.isObject(files[key])) {
if (files[key].constructor === File) {
mkdirp.sync(path.dirname(files[key].path));
fs.mkdirSync(path.dirname(files[key].path), { recursive: true });
fs.writeFileSync(files[key].path, files[key].contents);
++written;
} else {
Expand All @@ -89,7 +88,7 @@ function writeFiles(files) {
*/
function writeFile(file, content) {
try {
mkdirp.sync(path.dirname(file));
fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file, content);
return file;
} catch (e) {
Expand Down Expand Up @@ -129,7 +128,7 @@ function capturePhantom(src, target, cb) {
* @param {String} msg Message
*/
function compareSvg2Png(svg, png, expected, diff, done, msg) {
mkdirp.sync(path.dirname(png));
fs.mkdirSync(path.dirname(png), { recursive: true });
var ecb = function (err) {
console.log(err);
should(err).not.ok;
Expand Down

0 comments on commit 0adacc3

Please sign in to comment.