node-tool-utils
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -0,1 +1,11 @@ | ||
<a name="1.2.0"></a> | ||
# [1.2.0](https://github.com/hubcarl/node-tool-utils/compare/1.1.1...1.2.0) (2019-01-22) | ||
### Features | ||
* add writeFile and readFile method ([ee56121](https://github.com/hubcarl/node-tool-utils/commit/ee56121)) | ||
<a name="1.1.1"></a> | ||
@@ -2,0 +12,0 @@ ## 1.1.1 (2018-10-10) |
@@ -11,4 +11,4 @@ 'use strict'; | ||
const glob = require('glob'); | ||
const mkdirp = require('mkdirp'); | ||
exports.resolve = (filename, baseDir) => { | ||
@@ -201,2 +201,23 @@ baseDir = baseDir || process.cwd(); | ||
} | ||
}; | ||
exports.writeFile = (filepath, content) => { | ||
try { | ||
mkdirp.sync(path.dirname(filepath)); | ||
fs.writeFileSync(filepath, typeof content === 'string' ? content : JSON.stringify(content, null, 2), 'utf8'); | ||
} catch (e) { | ||
console.error(`writeFile ${filepath} err`, e); | ||
} | ||
}; | ||
exports.readFile = filepath => { | ||
try { | ||
if (fs.existsSync(filepath)) { | ||
const content = fs.readFileSync(filepath, 'utf8'); | ||
return JSON.parse(content); | ||
} | ||
} catch (e) { | ||
/* istanbul ignore next */ | ||
} | ||
return undefined; | ||
}; |
{ | ||
"name": "node-tool-utils", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "node cross-platform tool library", | ||
@@ -18,6 +18,7 @@ "keywords": [ | ||
"cross-port-killer": "^1.0.1", | ||
"mkdirp": "^0.5.1", | ||
"node-glob": "^1.2.0", | ||
"node-http-server": "^8.1.2", | ||
"opn": "^5.4.0", | ||
"shelljs": "^0.8.2", | ||
"node-glob": "^1.2.0", | ||
"node-http-server": "^8.1.2" | ||
"shelljs": "^0.8.2" | ||
}, | ||
@@ -24,0 +25,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12283
237
7
10
+ Addedmkdirp@^0.5.1
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)