Skip to content

Commit aaa8ec2

Browse files
committed
[Issue #38] - Throws exception if app directory does not exist...
1 parent 8f66de6 commit aaa8ec2

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
### Fixes
1010

11+
- [Issue #38] - Throws exception if app directory does not exist or is empty
12+
1113
## [0.3.0] - 2018-03-30
1214

1315
### Additions

lib/chainlinks/builder.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,20 @@ let Builder = function() {
5858
}
5959

6060
// Check for an app directory to merge
61+
this._mergeCmd = false;
6162
if (this.dirMerge && this.dirMerge.length &&
6263
fs.existsSync(this.dirMerge)) {
6364

6465
// Create app directory path
6566
let mergePath = path.normalize(this.dirMerge);
67+
68+
// Check directory contents
69+
if (fs.readdirSync(mergePath).length) {
6670

67-
// Merge the directory
68-
this._mergeCmd = "cp -rf ../" + mergePath + "/* .";
71+
// Merge the directory
72+
this._mergeCmd = "cp -rf ../" + mergePath + "/* .";
73+
74+
}
6975

7076
}
7177

@@ -75,28 +81,25 @@ let Builder = function() {
7581
// Install
7682
if (
7783
this.binCmd(this.installCmd) &&
78-
this.binCmd(this.cleanupCmd) &&
79-
(this._mergeCmd && this.binCmd(this._mergeCmd)))
84+
this.binCmd(this.cleanupCmd))
8085
{
81-
82-
accept(payload);
8386

8487
}
8588
else {
8689
reject("Could not install");
8790
}
8891

8992
}
90-
else {
9193

92-
// Merge build
93-
if (this._mergeCmd && this.binCmd(this._mergeCmd)) {
94-
accept(payload);
95-
}
96-
else {
97-
reject("Could not merge");
98-
}
94+
// Merge build
95+
if (this._mergeCmd && this.binCmd(this._mergeCmd)) {
96+
9997
}
98+
else if (this._mergeCmd) {
99+
reject("Could not merge");
100+
}
101+
102+
accept(payload);
100103

101104
});
102105
}

0 commit comments

Comments
 (0)