Merge pull request #15 from JsSucks/utils

FileUtils writes
This commit is contained in:
Alexei Stukov 2018-01-17 09:36:33 +02:00 committed by GitHub
commit b4be857f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -121,6 +121,15 @@ class FileUtils {
});
}
static async writeFile(path, data) {
return new Promise((resolve, reject) => {
fs.writeFile(path, data, err => {
if (err) return reject(err);
resolve();
});
});
}
static async readJsonFromFile(path) {
let readFile;
try {
@ -136,6 +145,10 @@ class FileUtils {
throw (Object.assign(err, { path }));
}
}
static async writeJsonToFile(path, json) {
return this.writeFile(path, JSON.stringify(json));
}
}