move join path into utils module
This commit is contained in:
parent
55275136b0
commit
561caa9b0b
|
@ -2,7 +2,7 @@ var mkdirp = require('mkdirp');
|
||||||
var wrench = require('wrench');
|
var wrench = require('wrench');
|
||||||
var colors = require('colors');
|
var colors = require('colors');
|
||||||
var GethCommands = require('./geth_commands.js');
|
var GethCommands = require('./geth_commands.js');
|
||||||
var path = require('path');
|
var utils = require('./utils.js');
|
||||||
|
|
||||||
var Blockchain = function(blockchainConfig, Client) {
|
var Blockchain = function(blockchainConfig, Client) {
|
||||||
this.blockchainConfig = blockchainConfig;
|
this.blockchainConfig = blockchainConfig;
|
||||||
|
@ -55,7 +55,7 @@ Blockchain.prototype.initChainAndGetAddress = function() {
|
||||||
mkdirp.sync(this.datadir);
|
mkdirp.sync(this.datadir);
|
||||||
|
|
||||||
// copy mining script
|
// copy mining script
|
||||||
wrench.copyDirSyncRecursive(path.join(__dirname, "/../js"), ".embark/development/js", {forceDelete: true});
|
wrench.copyDirSyncRecursive(utils.joinPath(__dirname, "/../js"), ".embark/development/js", {forceDelete: true});
|
||||||
|
|
||||||
// check if an account already exists, create one if not, return address
|
// check if an account already exists, create one if not, return address
|
||||||
result = this.runCommand(this.client.listAccountsCommand());
|
result = this.runCommand(this.client.listAccountsCommand());
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var grunt = require('grunt');
|
var grunt = require('grunt');
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
var path = require('path');
|
|
||||||
var Plugins = require('./plugins.js');
|
var Plugins = require('./plugins.js');
|
||||||
|
var utils = require('./utils.js');
|
||||||
|
|
||||||
// TODO: add wrapper for fs so it can also work in the browser
|
// TODO: add wrapper for fs so it can also work in the browser
|
||||||
// can work with both read and save
|
// can work with both read and save
|
||||||
|
@ -157,12 +157,12 @@ Config.prototype.loadFiles = function(files) {
|
||||||
return file.indexOf('.') >= 0;
|
return file.indexOf('.') >= 0;
|
||||||
}).filter(function(file) {
|
}).filter(function(file) {
|
||||||
if (file === 'embark.js') {
|
if (file === 'embark.js') {
|
||||||
readFiles.push({filename: 'web3.js', content: fs.readFileSync(path.join(__dirname, "/../js/web3.js")).toString(), path: path.join(__dirname, "/../js/web3.js")});
|
readFiles.push({filename: 'web3.js', content: fs.readFileSync(utils.joinPath(__dirname, "/../js/web3.js")).toString(), path: utils.joinPath(__dirname, "/../js/web3.js")});
|
||||||
readFiles.push({filename: 'ipfs.js', content: fs.readFileSync(path.join(__dirname, "/../js/ipfs.js")).toString(), path: path.join(__dirname, "/../js/ipfs.js")});
|
readFiles.push({filename: 'ipfs.js', content: fs.readFileSync(utils.joinPath(__dirname, "/../js/ipfs.js")).toString(), path: utils.joinPath(__dirname, "/../js/ipfs.js")});
|
||||||
// TODO: remove duplicated files if funcitonality is the same for storage and orbit
|
// TODO: remove duplicated files if funcitonality is the same for storage and orbit
|
||||||
readFiles.push({filename: 'ipfs-api.js', content: fs.readFileSync(path.join(__dirname, "/../js/ipfs-api.min.js")).toString(), path: path.join(__dirname, "/../js/ipfs-api.min.js")});
|
readFiles.push({filename: 'ipfs-api.js', content: fs.readFileSync(utils.joinPath(__dirname, "/../js/ipfs-api.min.js")).toString(), path: utils.joinPath(__dirname, "/../js/ipfs-api.min.js")});
|
||||||
readFiles.push({filename: 'orbit.js', content: fs.readFileSync(path.join(__dirname, "/../js/orbit.min.js")).toString(), path: path.join(__dirname, "/../js/orbit.min.js")});
|
readFiles.push({filename: 'orbit.js', content: fs.readFileSync(utils.joinPath(__dirname, "/../js/orbit.min.js")).toString(), path: utils.joinPath(__dirname, "/../js/orbit.min.js")});
|
||||||
readFiles.push({filename: 'embark.js', content: fs.readFileSync(path.join(__dirname, "/../js/build/embark.bundle.js")).toString(), path: path.join(__dirname, "/../js/build/embark.bundle.js")});
|
readFiles.push({filename: 'embark.js', content: fs.readFileSync(utils.joinPath(__dirname, "/../js/build/embark.bundle.js")).toString(), path: utils.joinPath(__dirname, "/../js/build/embark.bundle.js")});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*jshint esversion: 6, loopfunc: true */
|
/*jshint esversion: 6, loopfunc: true */
|
||||||
var grunt = require('grunt');
|
var grunt = require('grunt');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var utils = require('./utils.js');
|
||||||
|
|
||||||
// TODO: pass other params like blockchainConfig, contract files, etc..
|
// TODO: pass other params like blockchainConfig, contract files, etc..
|
||||||
var Plugin = function(options) {
|
var Plugin = function(options) {
|
||||||
|
@ -34,7 +34,7 @@ Plugin.prototype.loadPluginFile = function(filename) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugin.prototype.pathToFile = function(filename) {
|
Plugin.prototype.pathToFile = function(filename) {
|
||||||
return path.join(this.pluginPath, filename);
|
return utils.joinPath(this.pluginPath, filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugin.prototype.interceptLogs = function(context) {
|
Plugin.prototype.interceptLogs = function(context) {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
var Plugin = require('./plugin.js');
|
var Plugin = require('./plugin.js');
|
||||||
var path = require('path');
|
|
||||||
|
|
||||||
var Plugins = function(options) {
|
var Plugins = function(options) {
|
||||||
this.pluginList = options.plugins || [];
|
this.pluginList = options.plugins || [];
|
||||||
|
@ -26,7 +25,7 @@ Plugins.prototype.listPlugins = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugins.prototype.loadPlugin = function(pluginName, pluginConfig) {
|
Plugins.prototype.loadPlugin = function(pluginName, pluginConfig) {
|
||||||
var pluginPath = path.join(process.env.PWD, 'node_modules', pluginName);
|
var pluginPath = utils.joinPath(process.env.PWD, 'node_modules', pluginName);
|
||||||
var plugin = require(pluginPath);
|
var plugin = require(pluginPath);
|
||||||
|
|
||||||
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs});
|
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// TODO: replace with something else more native to node
|
// TODO: replace with something else more native to node
|
||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
var path = require('path');
|
|
||||||
var wrench = require('wrench');
|
var wrench = require('wrench');
|
||||||
|
var utils = require('./utils.js');
|
||||||
|
|
||||||
var run = function(cmd) {
|
var run = function(cmd) {
|
||||||
var result = exec(cmd, {silent: true});
|
var result = exec(cmd, {silent: true});
|
||||||
|
@ -20,7 +20,7 @@ var TemplateGenerator = function(templateName) {
|
||||||
};
|
};
|
||||||
|
|
||||||
TemplateGenerator.prototype.generate = function(destinationFolder, name) {
|
TemplateGenerator.prototype.generate = function(destinationFolder, name) {
|
||||||
var templatePath = path.join(__dirname, '/../', this.templateName);
|
var templatePath = utils.joinPath(__dirname, '/../', this.templateName);
|
||||||
console.log('Initializing Embark Template....'.green);
|
console.log('Initializing Embark Template....'.green);
|
||||||
|
|
||||||
wrench.copyDirSyncRecursive(templatePath, destinationFolder + name);
|
wrench.copyDirSyncRecursive(templatePath, destinationFolder + name);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
function joinPath() {
|
||||||
|
return path.join.apply(path.join, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
joinPath: joinPath
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue