prefer joinPath to +'ing strings together
This commit is contained in:
parent
40c14a08de
commit
8be1090a44
|
@ -169,7 +169,7 @@ Config.prototype._getFileOrOject = function(object, filePath, property) {
|
||||||
if (typeof (this.configDir) === 'object') {
|
if (typeof (this.configDir) === 'object') {
|
||||||
return this.configDir[property];
|
return this.configDir[property];
|
||||||
}
|
}
|
||||||
return this.configDir + filePath;
|
return utils.joinPath(this.configDir, filePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
Config.prototype.loadBlockchainConfigFile = function() {
|
Config.prototype.loadBlockchainConfigFile = function() {
|
||||||
|
|
|
@ -31,10 +31,7 @@ class Pipeline {
|
||||||
function createPlaceholderPage(next){
|
function createPlaceholderPage(next){
|
||||||
self.events.request('embark-building-placeholder', (html) => {
|
self.events.request('embark-building-placeholder', (html) => {
|
||||||
fs.mkdirpSync(self.buildDir); // create dist/ folder if not already exists
|
fs.mkdirpSync(self.buildDir); // create dist/ folder if not already exists
|
||||||
fs.writeFile(self.buildDir + 'index.html', html, next);
|
fs.writeFile(utils.joinPath(self.buildDir, 'index.html'), html, next);
|
||||||
// ^ ?? should this use path.join instead? templates' embark.json
|
|
||||||
// files have a '/' hardcoded on the end of buildDir but that doesn't
|
|
||||||
// seem too resilient
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function buildTheContracts(next) {
|
function buildTheContracts(next) {
|
||||||
|
@ -117,7 +114,7 @@ class Pipeline {
|
||||||
const isDir = targetFile.slice(-1) === '/' || targetFile.indexOf('.') === -1;
|
const isDir = targetFile.slice(-1) === '/' || targetFile.indexOf('.') === -1;
|
||||||
// if it's not a directory
|
// if it's not a directory
|
||||||
if (!isDir) {
|
if (!isDir) {
|
||||||
self.logger.info(__("writing file") + " " + (self.buildDir + targetFile).bold.dim);
|
self.logger.info(__("writing file") + " " + (utils.joinPath(self.buildDir, targetFile)).bold.dim);
|
||||||
}
|
}
|
||||||
async.map(
|
async.map(
|
||||||
files,
|
files,
|
||||||
|
@ -160,8 +157,8 @@ class Pipeline {
|
||||||
self.logger.error(__('errors found while generating') + ' ' + targetFile);
|
self.logger.error(__('errors found while generating') + ' ' + targetFile);
|
||||||
}
|
}
|
||||||
let dir = targetFile.split('/').slice(0, -1).join('/');
|
let dir = targetFile.split('/').slice(0, -1).join('/');
|
||||||
self.logger.trace("creating dir " + self.buildDir + dir);
|
self.logger.trace("creating dir " + utils.joinPath(self.buildDir, dir));
|
||||||
fs.mkdirpSync(self.buildDir + dir);
|
fs.mkdirpSync(utils.joinPath(self.buildDir, dir));
|
||||||
|
|
||||||
// if it's a directory
|
// if it's a directory
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
|
@ -173,9 +170,9 @@ class Pipeline {
|
||||||
|
|
||||||
async.each(contentFiles, function (file, mapCb) {
|
async.each(contentFiles, function (file, mapCb) {
|
||||||
let filename = file.filename.replace(file.basedir + '/', '');
|
let filename = file.filename.replace(file.basedir + '/', '');
|
||||||
self.logger.info("writing file " + (self.buildDir + targetDir + filename).bold.dim);
|
self.logger.info("writing file " + (utils.joinPath(self.buildDir, targetDir, filename)).bold.dim);
|
||||||
|
|
||||||
fs.copy(file.path, self.buildDir + targetDir + filename, {overwrite: true}, mapCb);
|
fs.copy(file.path, utils.joinPath(self.buildDir, targetDir, filename), {overwrite: true}, mapCb);
|
||||||
}, cb);
|
}, cb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +188,7 @@ class Pipeline {
|
||||||
targetFile = targetFile.replace('index', 'index-temp');
|
targetFile = targetFile.replace('index', 'index-temp');
|
||||||
placeholderPage = targetFile;
|
placeholderPage = targetFile;
|
||||||
}
|
}
|
||||||
fs.writeFile(self.buildDir + targetFile, content, cb);
|
fs.writeFile(utils.joinPath(self.buildDir, targetFile), content, cb);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -199,8 +196,8 @@ class Pipeline {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
function removePlaceholderPage(next){
|
function removePlaceholderPage(next){
|
||||||
let placeholderFile = self.buildDir + placeholderPage;
|
let placeholderFile = utils.joinPath(self.buildDir, placeholderPage);
|
||||||
fs.access(self.buildDir + placeholderPage, (err) => {
|
fs.access(utils.joinPath(self.buildDir, placeholderPage), (err) => {
|
||||||
if (err) return next(); // index-temp doesn't exist, do nothing
|
if (err) return next(); // index-temp doesn't exist, do nothing
|
||||||
|
|
||||||
// rename index-temp.htm/l to index.htm/l, effectively replacing our placeholder page
|
// rename index-temp.htm/l to index.htm/l, effectively replacing our placeholder page
|
||||||
|
|
Loading…
Reference in New Issue