Skip to content

Commit

Permalink
refactor: Replacing mkdirp with native mkdir recursive (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian authored Feb 25, 2021
1 parent 977d59a commit c9c48db
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-monkeys-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Replacing mkdirp with native mkdir recursive
3 changes: 1 addition & 2 deletions packages/cli/lib/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { promisify } = require('util');
const fetch = require('isomorphic-unfetch');
const glob = promisify(require('glob').glob);
const gittar = require('gittar');
const mkdirp = require('mkdirp');
const fs = require('../fs');
const os = require('os');
const { green } = require('kleur');
Expand Down Expand Up @@ -271,7 +270,7 @@ async function command(repo, dest, argv) {
}

if (!fs.existsSync(resolve(cwd, dest, 'src'))) {
mkdirp.sync(resolve(cwd, dest, 'src'));
fs.mkdirSync(resolve(cwd, dest, 'src'), { recursive: true });
}

// Attempt to fetch the `template`
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/lib/fs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {
mkdir,
mkdirSync,
readFile,
writeFile,
copyFile,
Expand All @@ -11,6 +12,7 @@ const { promisify } = require('util');

module.exports = {
mkdir: promisify(mkdir),
mkdirSync,
copyFile: promisify(copyFile),
readFile: promisify(readFile),
writeFile: promisify(writeFile),
Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"devDependencies": {
"html-looks-like": "^1.0.2",
"jest": "^26.0.1",
"mkdirp": "^1.0.3",
"ncp": "^2.0.0",
"node-sass": "^4.12.0",
"p-retry": "^4.1.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/tests/lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { join } = require('path');
const { existsSync, unlinkSync, symlinkSync } = require('fs');
const { existsSync, mkdirSync, unlinkSync, symlinkSync } = require('fs');
const cmd = require('../../lib/commands');
const { tmpDir } = require('./output');
const mkdirp = require('mkdirp');
const shell = require('shelljs');

const root = join(__dirname, '../../../..');
Expand Down Expand Up @@ -37,7 +36,7 @@ exports.create = async function (template, name) {

exports.build = function (cwd, options, installNodeModules = false) {
if (!installNodeModules) {
mkdirp.sync(join(cwd, 'node_modules')); // ensure exists, avoid exit()
mkdirSync(join(cwd, 'node_modules'), { recursive: true }); // ensure exists, avoid exit()
linkPackage('preact', root, cwd);
linkPackage('preact-render-to-string', root, cwd);
} else {
Expand Down

0 comments on commit c9c48db

Please sign in to comment.