Commit 138bc5bb authored by Aral Balkan's avatar Aral Balkan

No longer crashes with multiple missing directories on nodecert path

(Behaves like mkdir -p when creating it.)
parent d1323835
...@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Nothing yet. Nothing yet.
## [3.1.3] - 2019-11-26
### Fixed
- No longer crashes if multiple directories do not exist in the requested nodecert path.
## [3.1.2] - 2019-11-25 ## [3.1.2] - 2019-11-25
### Changed ### Changed
......
const os = require('os') const os = require('os')
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs-extra')
const childProcess = require('child_process') const childProcess = require('child_process')
const _platform = os.platform() const _platform = os.platform()
...@@ -21,10 +21,8 @@ module.exports = function (_nodecertDir = path.join(homeDir, '.small-tech.org', ...@@ -21,10 +21,8 @@ module.exports = function (_nodecertDir = path.join(homeDir, '.small-tech.org',
console.log('\n 🆕 [Nodecert] Setting up…') console.log('\n 🆕 [Nodecert] Setting up…')
// Create the directory if it doesn’t already exist. // Ensure the nodecert directory exists.
if (!fs.existsSync(nodecertDir)) { fs.ensureDirSync(nodecertDir)
fs.mkdirSync(nodecertDir)
}
// Get a path to the mkcert binary for this machine. // Get a path to the mkcert binary for this machine.
const mkcertBinary = mkcertBinaryForThisMachine() const mkcertBinary = mkcertBinaryForThisMachine()
......
{ {
"name": "@ind.ie/nodecert", "name": "@ind.ie/nodecert",
"version": "3.0.1", "version": "3.1.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
...@@ -81,6 +81,16 @@ ...@@ -81,6 +81,16 @@
"is-callable": "^1.1.3" "is-callable": "^1.1.3"
} }
}, },
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs.realpath": { "fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
...@@ -107,6 +117,11 @@ ...@@ -107,6 +117,11 @@
"path-is-absolute": "^1.0.0" "path-is-absolute": "^1.0.0"
} }
}, },
"graceful-fs": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz",
"integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ=="
},
"has": { "has": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
...@@ -168,6 +183,14 @@ ...@@ -168,6 +183,14 @@
"has-symbols": "^1.0.0" "has-symbols": "^1.0.0"
} }
}, },
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"requires": {
"graceful-fs": "^4.1.6"
}
},
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
...@@ -277,6 +300,11 @@ ...@@ -277,6 +300,11 @@
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true "dev": true
}, },
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
},
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
......
{ {
"name": "@ind.ie/nodecert", "name": "@ind.ie/nodecert",
"version": "3.1.2", "version": "3.1.3",
"description": "Automatically provision and use locally-trusted TLS certificates in Node.js using mkcert.", "description": "Automatically provision and use locally-trusted TLS certificates in Node.js using mkcert.",
"main": "index.js", "main": "index.js",
"bin": "bin/nodecert.js", "bin": "bin/nodecert.js",
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
}, },
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"fs-extra": "^8.1.0",
"syswide-cas": "^5.3.0" "syswide-cas": "^5.3.0"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -41,7 +41,7 @@ test('certificate creation', t => { ...@@ -41,7 +41,7 @@ test('certificate creation', t => {
// Custom nodecert directory. // Custom nodecert directory.
// //
nodecertDirectory = path.join(os.homedir(), '.small-tech.org', 'nodecert-custom-directory-test') nodecertDirectory = path.join(os.homedir(), '.small-tech.org', 'nodecert-custom-directory-test', 'second-level-directory')
if (fs.existsSync(nodecertDirectory)) { if (fs.existsSync(nodecertDirectory)) {
// Clear the .nodecert directory if it already exists. // Clear the .nodecert directory if it already exists.
rmRFSync(nodecertDirectory) rmRFSync(nodecertDirectory)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment