From 8da0e80751d023c31561cba2ef24aa4b7d3c6014 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 19 Feb 2017 11:37:54 -0500 Subject: [PATCH] move fs methods into their own module --- lib/blockchain.js | 2 +- lib/config.js | 2 +- lib/deploy_tracker.js | 2 +- lib/fs.js | 30 ++++++++++++++++++++++++++++++ lib/pipeline.js | 2 +- lib/plugin.js | 2 +- lib/template_generator.js | 2 +- lib/watch.js | 2 +- 8 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 lib/fs.js diff --git a/lib/blockchain.js b/lib/blockchain.js index 4736779e3..2081e1ba7 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -1,4 +1,4 @@ -var fs = require('fs-extra'); +var fs = require('./fs.js'); var colors = require('colors'); var GethCommands = require('./geth_commands.js'); var utils = require('./utils.js'); diff --git a/lib/config.js b/lib/config.js index d1115ea0b..f2a589a3b 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,4 +1,4 @@ -var fs = require('fs-extra'); +var fs = require('./fs.js'); var Plugins = require('./plugins.js'); var utils = require('./utils.js'); diff --git a/lib/deploy_tracker.js b/lib/deploy_tracker.js index 8a792923d..35a7048ba 100644 --- a/lib/deploy_tracker.js +++ b/lib/deploy_tracker.js @@ -1,4 +1,4 @@ -var fs = require('fs-extra'); +var fs = require('./fs.js'); var DeployTracker = function(options) { this.logger = options.logger; diff --git a/lib/fs.js b/lib/fs.js new file mode 100644 index 000000000..77bfb3de8 --- /dev/null +++ b/lib/fs.js @@ -0,0 +1,30 @@ +var fs = require('fs-extra'); + +function mkdirpSync() { + return fs.mkdirpSync.apply(fs.mkdirpSync, arguments); +} + +function copySync() { + return fs.copySync.apply(fs.copySync, arguments); +} + +function readFileSync() { + return fs.readFileSync.apply(fs.readFileSync, arguments); +} + +function readJSONSync() { + return fs.readJSONSync.apply(fs.readJSONSync, arguments); +} + +function writeJSONSync() { + return fs.writeJSONSync.apply(fs.writeJSONSync, arguments); +} + +module.exports = { + mkdirpSync: mkdirpSync, + copySync: copySync, + readFileSync: readFileSync, + readJSONSync: readJSONSync, + writeJSONSync: writeJSONSync +}; + diff --git a/lib/pipeline.js b/lib/pipeline.js index 010f32a11..51d76b2ef 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -1,5 +1,5 @@ /*jshint esversion: 6, loopfunc: true */ -var fs = require('fs-extra'); +var fs = require('./fs.js'); var Pipeline = function(options) { this.buildDir = options.buildDir; diff --git a/lib/plugin.js b/lib/plugin.js index fd7e04723..1b579c85d 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,5 +1,5 @@ /*jshint esversion: 6, loopfunc: true */ -var fs = require('fs-extra'); +var fs = require('./fs.js'); var utils = require('./utils.js'); // TODO: pass other params like blockchainConfig, contract files, etc.. diff --git a/lib/template_generator.js b/lib/template_generator.js index 1befd03a6..c61dc1362 100644 --- a/lib/template_generator.js +++ b/lib/template_generator.js @@ -1,4 +1,4 @@ -var fs = require('fs-extra'); +var fs = require('./fs.js'); var utils = require('./utils.js'); var TemplateGenerator = function(templateName) { diff --git a/lib/watch.js b/lib/watch.js index fa68d056c..56b92f0c8 100644 --- a/lib/watch.js +++ b/lib/watch.js @@ -1,5 +1,5 @@ /*jshint esversion: 6 */ -var fs = require('fs-extra'); +var fs = require('./fs.js'); var chokidar = require('chokidar'); // TODO: this should be receiving the config object not re-reading the