2017-12-19 17:57:03 +00:00
|
|
|
const parseJson = require('parse-json');
|
2017-03-29 17:50:05 +00:00
|
|
|
let fs = require('fs-extra');
|
|
|
|
let utils = require('../utils/utils.js');
|
2017-12-19 17:57:03 +00:00
|
|
|
require('colors');
|
2017-02-19 16:37:54 +00:00
|
|
|
|
|
|
|
function mkdirpSync() {
|
|
|
|
return fs.mkdirpSync.apply(fs.mkdirpSync, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
function copySync() {
|
|
|
|
return fs.copySync.apply(fs.copySync, arguments);
|
|
|
|
}
|
|
|
|
|
2017-02-19 17:51:32 +00:00
|
|
|
function writeFileSync() {
|
|
|
|
return fs.writeFileSync.apply(fs.writeFileSync, arguments);
|
|
|
|
}
|
|
|
|
|
2017-02-19 16:37:54 +00:00
|
|
|
function readFileSync() {
|
|
|
|
return fs.readFileSync.apply(fs.readFileSync, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
function readJSONSync() {
|
2017-12-19 17:57:03 +00:00
|
|
|
let content = readFileSync.apply(readFileSync, arguments);
|
|
|
|
try {
|
|
|
|
return parseJson(content);
|
|
|
|
} catch(e) {
|
|
|
|
console.error("error: ".red + arguments[0].green.underline + " " + e.message.green);
|
|
|
|
process.exit(0);
|
|
|
|
}
|
2017-02-19 16:37:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function writeJSONSync() {
|
|
|
|
return fs.writeJSONSync.apply(fs.writeJSONSync, arguments);
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
function existsSync() {
|
2017-02-21 20:45:10 +00:00
|
|
|
return fs.existsSync.apply(fs.existsSync, arguments);
|
|
|
|
}
|
|
|
|
|
2018-01-11 14:22:58 +00:00
|
|
|
function removeSync() {
|
|
|
|
return fs.removeSync.apply(fs.removeSync, arguments);
|
|
|
|
}
|
|
|
|
|
2017-02-20 00:44:16 +00:00
|
|
|
// returns embarks root directory
|
|
|
|
function embarkPath(fileOrDir) {
|
|
|
|
return utils.joinPath(__dirname, '/../../', fileOrDir);
|
|
|
|
}
|
|
|
|
|
2017-07-05 12:35:51 +00:00
|
|
|
function dappPath() {
|
|
|
|
return process.env.PWD;
|
|
|
|
}
|
|
|
|
|
2017-02-19 16:37:54 +00:00
|
|
|
module.exports = {
|
|
|
|
mkdirpSync: mkdirpSync,
|
|
|
|
copySync: copySync,
|
|
|
|
readFileSync: readFileSync,
|
2017-02-19 17:51:32 +00:00
|
|
|
writeFileSync: writeFileSync,
|
2017-02-19 16:37:54 +00:00
|
|
|
readJSONSync: readJSONSync,
|
2017-02-20 00:44:16 +00:00
|
|
|
writeJSONSync: writeJSONSync,
|
2017-02-21 20:45:10 +00:00
|
|
|
existsSync: existsSync,
|
2018-01-11 14:22:58 +00:00
|
|
|
removeSync: removeSync,
|
2017-12-07 20:27:03 +00:00
|
|
|
embarkPath: embarkPath,
|
|
|
|
dappPath: dappPath
|
2017-02-19 16:37:54 +00:00
|
|
|
};
|