cob-cli 2.39.1 → 2.39.2
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 +21 -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
|
|
@@ -203,6 +205,7 @@ function copyAndMerge(customizationRepoName, source, substitutions = {}) {
|
|
|
203
205
|
transform(read, write) {
|
|
204
206
|
const replaceVarsTransformFunction = new Transform({
|
|
205
207
|
transform: (chunk, encoding, done) => {
|
|
208
|
+
if(chunk.toString().indexOf("_log.css") > 0) console.log(chunk.toString())
|
|
206
209
|
if(/\ufffd/.test(chunk) === true) {
|
|
207
210
|
// If chunk is binary don't change anything
|
|
208
211
|
done(null, chunk)
|
|
@@ -218,6 +221,12 @@ function copyAndMerge(customizationRepoName, source, substitutions = {}) {
|
|
|
218
221
|
(error) => {
|
|
219
222
|
if(error) {
|
|
220
223
|
console.log(error.map((e) => e.message).join("\n"))
|
|
224
|
+
} else {
|
|
225
|
+
// Only run this on the last call
|
|
226
|
+
for(let file of filesToMerge) {
|
|
227
|
+
//Allow a little time for file to be written to disk
|
|
228
|
+
setTimeout(() => mergeFiles(customizationRepoName, file), 200)
|
|
229
|
+
}
|
|
221
230
|
}
|
|
222
231
|
}
|
|
223
232
|
)
|
|
@@ -225,13 +234,22 @@ function copyAndMerge(customizationRepoName, source, substitutions = {}) {
|
|
|
225
234
|
|
|
226
235
|
/* ************************************************************************ */
|
|
227
236
|
function mergeFiles(block,mergeFile) {
|
|
228
|
-
|
|
237
|
+
if (!fs.existsSync(mergeFile)) {
|
|
238
|
+
//Already processed
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let prodFileRexp = new RegExp(block + "__MERGE__.");
|
|
243
|
+
let prodFile = mergeFile.replace(prodFileRexp, "");
|
|
229
244
|
let blockMark = block == undefined ? "" : block;
|
|
230
245
|
if (!fs.existsSync(prodFile)) {
|
|
231
246
|
// If prod file does not exist creates it
|
|
232
247
|
console.log(" Creating " + prodFile);
|
|
233
248
|
fs.closeSync(fs.openSync(prodFile, "w"));
|
|
234
249
|
} else {
|
|
250
|
+
fs.open(prodFile, "a+",(err, fd) => {
|
|
251
|
+
fs.fdatasync(fd /*, optional callback here */);
|
|
252
|
+
})
|
|
235
253
|
console.log(" Merging " + prodFile + " " + block);
|
|
236
254
|
}
|
|
237
255
|
let prodFileContent = fs.readFileSync(prodFile).toString();
|
package/package.json
CHANGED