cob-cli 2.39.1 → 2.39.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/customize.js +20 -3
- package/package.json +1 -1
|
@@ -177,6 +177,7 @@ function copyAndMerge(customizationRepoName, source, substitutions = {}) {
|
|
|
177
177
|
// Source is on cob-cli customizationRepo and Destination on the server repo
|
|
178
178
|
const target = process.cwd() // Always copy to directory where command is being executed, ie, the root directory of the server repo
|
|
179
179
|
const substitutionRegex = /__(((?!word).)*)__/g;
|
|
180
|
+
let filesToMerge = []
|
|
180
181
|
ncp(
|
|
181
182
|
source,
|
|
182
183
|
target,
|
|
@@ -186,8 +187,9 @@ function copyAndMerge(customizationRepoName, source, substitutions = {}) {
|
|
|
186
187
|
rename: function(target) {
|
|
187
188
|
// Don't rename __MERGE__ templates, they will be handled by the merge method
|
|
188
189
|
if (target.match(/__MERGE__/)) {
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
const newTmpName = target.replace(/__MERGE__/, customizationRepoName+"__MERGE__")
|
|
191
|
+
filesToMerge.push(newTmpName)
|
|
192
|
+
return newTmpName
|
|
191
193
|
};
|
|
192
194
|
|
|
193
195
|
//get finalTarget from target with any existing substitution
|
|
@@ -218,6 +220,12 @@ function copyAndMerge(customizationRepoName, source, substitutions = {}) {
|
|
|
218
220
|
(error) => {
|
|
219
221
|
if(error) {
|
|
220
222
|
console.log(error.map((e) => e.message).join("\n"))
|
|
223
|
+
} else {
|
|
224
|
+
// Only run this on the last call
|
|
225
|
+
for(let file of filesToMerge) {
|
|
226
|
+
//Allow a little time for file to be written to disk
|
|
227
|
+
setTimeout(() => mergeFiles(customizationRepoName, file), 200)
|
|
228
|
+
}
|
|
221
229
|
}
|
|
222
230
|
}
|
|
223
231
|
)
|
|
@@ -225,13 +233,22 @@ function copyAndMerge(customizationRepoName, source, substitutions = {}) {
|
|
|
225
233
|
|
|
226
234
|
/* ************************************************************************ */
|
|
227
235
|
function mergeFiles(block,mergeFile) {
|
|
228
|
-
|
|
236
|
+
if (!fs.existsSync(mergeFile)) {
|
|
237
|
+
//Already processed
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
let prodFileRexp = new RegExp(block + "__MERGE__.");
|
|
242
|
+
let prodFile = mergeFile.replace(prodFileRexp, "");
|
|
229
243
|
let blockMark = block == undefined ? "" : block;
|
|
230
244
|
if (!fs.existsSync(prodFile)) {
|
|
231
245
|
// If prod file does not exist creates it
|
|
232
246
|
console.log(" Creating " + prodFile);
|
|
233
247
|
fs.closeSync(fs.openSync(prodFile, "w"));
|
|
234
248
|
} else {
|
|
249
|
+
fs.open(prodFile, "a+",(err, fd) => {
|
|
250
|
+
fs.fdatasync(fd /*, optional callback here */);
|
|
251
|
+
})
|
|
235
252
|
console.log(" Merging " + prodFile + " " + block);
|
|
236
253
|
}
|
|
237
254
|
let prodFileContent = fs.readFileSync(prodFile).toString();
|
package/package.json
CHANGED