mirror of https://github.com/embarklabs/embark.git
improve directory copying
This commit is contained in:
parent
c84ef36b35
commit
349807496a
|
@ -2,6 +2,7 @@ var fs = require('./fs.js');
|
||||||
var File = require('./file.js');
|
var File = require('./file.js');
|
||||||
var Plugins = require('./plugins.js');
|
var Plugins = require('./plugins.js');
|
||||||
var utils = require('../utils/utils.js');
|
var utils = require('../utils/utils.js');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
var Config = function(options) {
|
var Config = function(options) {
|
||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
|
@ -188,6 +189,18 @@ Config.prototype.loadChainTrackerFile = function() {
|
||||||
this.chainTracker = fs.readJSONSync(this.chainsFile);
|
this.chainTracker = fs.readJSONSync(this.chainsFile);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function findMatchingExpression(filename, filesExpressions) {
|
||||||
|
for (let fileExpression of filesExpressions) {
|
||||||
|
var matchingFiles = utils.filesMatchingPattern(fileExpression);
|
||||||
|
for (matchFile of matchingFiles) {
|
||||||
|
if (matchFile === filename) {
|
||||||
|
return path.dirname(fileExpression).replace(/\*/g, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path.dirname(filename)
|
||||||
|
}
|
||||||
|
|
||||||
Config.prototype.loadFiles = function(files) {
|
Config.prototype.loadFiles = function(files) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var originalFiles = utils.filesMatchingPattern(files);
|
var originalFiles = utils.filesMatchingPattern(files);
|
||||||
|
@ -196,7 +209,8 @@ Config.prototype.loadFiles = function(files) {
|
||||||
originalFiles.filter(function(file) {
|
originalFiles.filter(function(file) {
|
||||||
return (file[0] === '$' || file.indexOf('.') >= 0);
|
return (file[0] === '$' || file.indexOf('.') >= 0);
|
||||||
}).filter(function(file) {
|
}).filter(function(file) {
|
||||||
readFiles.push(new File({filename: file, type: "dapp_file", path: file}));
|
let basedir = findMatchingExpression(file, files);
|
||||||
|
readFiles.push(new File({filename: file, type: "dapp_file", basedir: basedir, path: file}));
|
||||||
});
|
});
|
||||||
|
|
||||||
var filesFromPlugins = [];
|
var filesFromPlugins = [];
|
||||||
|
|
|
@ -6,6 +6,7 @@ class File {
|
||||||
this.filename = options.filename;
|
this.filename = options.filename;
|
||||||
this.type = options.type;
|
this.type = options.type;
|
||||||
this.path = options.path;
|
this.path = options.path;
|
||||||
|
this.basedir = options.basedir;
|
||||||
this.resolver = options.resolver;
|
this.resolver = options.resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,12 +111,12 @@ class Pipeline {
|
||||||
return fileCb("couldn't find file: " + file.filename);
|
return fileCb("couldn't find file: " + file.filename);
|
||||||
}
|
}
|
||||||
let fileContent = fs.readFileSync('./.embark/' + file.filename).toString();
|
let fileContent = fs.readFileSync('./.embark/' + file.filename).toString();
|
||||||
fileCb(null, {content: fileContent, filename: file.filename, path: file.path, modified: true});
|
fileCb(null, {content: fileContent, filename: file.filename, path: file.path, basedir: file.basedir, modified: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
file.content(function(fileContent) {
|
file.content(function(fileContent) {
|
||||||
return fileCb(null, {content: fileContent, filename: file.filename, path: file.path, modified: true});
|
return fileCb(null, {content: fileContent, filename: file.filename, path: file.path, basedir: file.basedir, modified: true});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,8 +138,7 @@ class Pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
contentFiles.map(function (file) {
|
contentFiles.map(function (file) {
|
||||||
let filename = file.filename.replace('app/', '');
|
let filename = file.filename.replace(file.basedir + '/', '');
|
||||||
filename = filename.replace(targetDir, '');
|
|
||||||
self.logger.info("writing file " + (self.buildDir + targetDir + filename).bold.dim);
|
self.logger.info("writing file " + (self.buildDir + targetDir + filename).bold.dim);
|
||||||
|
|
||||||
fs.copySync(file.path, self.buildDir + targetDir + filename, {overwrite: true});
|
fs.copySync(file.path, self.buildDir + targetDir + filename, {overwrite: true});
|
||||||
|
|
Loading…
Reference in New Issue