Merge pull request #742 from embark-framework/bug_fix/template-destination
don't continue with template install if destination path exists
This commit is contained in:
commit
9311bf2d30
|
@ -6,7 +6,16 @@ class TemplateGenerator {
|
|||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
checkPathExists(fspath) {
|
||||
if (fs.existsSync(fspath)) {
|
||||
console.error(`${fspath} already exists, will not overwrite`.red);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
downloadAndGenerate(uri, destinationFolder, name) {
|
||||
const fspath = utils.joinPath(destinationFolder, name);
|
||||
this.checkPathExists(fspath);
|
||||
const self = this;
|
||||
let {url, filePath} = this.getExternalProject(uri);
|
||||
let tmpFilePath = fs.tmpDir(filePath);
|
||||
|
@ -14,8 +23,6 @@ class TemplateGenerator {
|
|||
|
||||
fs.mkdirpSync(utils.dirname(tmpFilePath));
|
||||
utils.downloadFile(url, tmpFilePath, () => {
|
||||
let fspath = utils.joinPath(destinationFolder, name);
|
||||
|
||||
utils.extractZip(tmpFilePath, fspath, {
|
||||
map: file => {
|
||||
let fixed_path = file.path.split('/');
|
||||
|
@ -30,10 +37,11 @@ class TemplateGenerator {
|
|||
}
|
||||
|
||||
generate(destinationFolder, name) {
|
||||
const fspath = utils.joinPath(destinationFolder, name);
|
||||
this.checkPathExists(fspath);
|
||||
console.log(__('Initializing Embark Template...').green);
|
||||
|
||||
let templatePath = fs.embarkPath(utils.joinPath('templates', this.templateName));
|
||||
let fspath = utils.joinPath(destinationFolder, name);
|
||||
fs.copySync(templatePath, fspath);
|
||||
|
||||
this.installTemplate(fspath, name, (name === 'embark_demo'));
|
||||
|
|
Loading…
Reference in New Issue