@jtff/miztemplate-lib 3.0.5 → 3.0.7

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.
@@ -250,7 +250,10 @@ class MizTemplateCI{
250
250
  }
251
251
 
252
252
  async InjectCiScriptsIntoWorkspace(workspacePath) {
253
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/ci',workspacePath + '/.workspace/src/nodejs',{recursive: true});
253
+
254
+ this.mizlib.copyRecursiveSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/ci', workspacePath + '/.workspace/src/nodejs');
255
+
256
+ // fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/ci',workspacePath + '/.workspace/src/nodejs',{recursive: true});
254
257
  }
255
258
 
256
259
  async deployCIScriptsFromZipObjectIntoWorkspace(workspacePath, mizObject, mizFilePath) {
package/lib/mizlib.js CHANGED
@@ -42,7 +42,19 @@ class Mizlib {
42
42
  colorString
43
43
  );
44
44
  for (let luaScript of luaScriptsArray) {
45
- fs.cpSync(
45
+ if (! fs.existsSync([
46
+ workspacePath,
47
+ fromLibrary ? "/.workspace/" : "/",
48
+ folderPath,
49
+ ].join("")
50
+ )) {
51
+ fs.mkdirSync([
52
+ workspacePath,
53
+ fromLibrary ? "/.workspace/" : "/",
54
+ folderPath,
55
+ ].join(""));
56
+ }
57
+ fs.copyFileSync(
46
58
  [
47
59
  getInstalledPathSync('@jtff/miztemplate-lib',{local: true}),
48
60
  '/lua/',
@@ -56,8 +68,7 @@ class Mizlib {
56
68
  folderPath,
57
69
  "/",
58
70
  path.basename(luaScript)
59
- ].join(""),
60
- {force: true}
71
+ ].join("")
61
72
  );
62
73
  }
63
74
  return tuple;
@@ -121,16 +132,14 @@ class Mizlib {
121
132
  .filter(filename => path.extname(filename).toLowerCase()==='.lua');
122
133
  for (let file of srcFiles) {
123
134
  console.log('updating src/' + file + ' from the miztemplate-lib');
124
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/src/' + file,
125
- '.workspace/src/' + file,
126
- {force: true}
135
+ fs.copyFileSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/src/' + file,
136
+ '.workspace/src/' + file
127
137
  );
128
138
  }
129
139
  for (let file of libFiles) {
130
140
  console.log('updating lib/' + file + ' from the miztemplate-lib');
131
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/lib/' + file,
132
- '.workspace/lib/' + file,
133
- {force: true}
141
+ fs.copyFileSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/lib/' + file,
142
+ '.workspace/lib/' + file
134
143
  );
135
144
  }
136
145
  this.injectLuaFilesFromFolderIntoZipObject(zipObject, '.workspace/src', mizSettingSubFolder);
@@ -330,6 +339,23 @@ class Mizlib {
330
339
  }
331
340
  }
332
341
 
342
+ copyRecursiveSync(src, dest) {
343
+ let self = this;
344
+ let exists = fs.existsSync(src);
345
+ let stats = exists && fs.statSync(src);
346
+ let isDirectory = exists && stats.isDirectory();
347
+ if (isDirectory) {
348
+ fs.mkdirSync(dest, {recursive: true});
349
+ fs.readdirSync(src).forEach(function(childItemName) {
350
+ self.copyRecursiveSync(path.join(src, childItemName),
351
+ path.join(dest, childItemName));
352
+ });
353
+ } else {
354
+ fs.copyFileSync(src, dest);
355
+ }
356
+ };
357
+
358
+
333
359
  async updateWorkspaceWithSingleSoundFolder(workspacePath, folderString) {
334
360
  if (
335
361
  fs.existsSync(
@@ -359,11 +385,16 @@ class Mizlib {
359
385
  "/.workspace/resources/sounds/",
360
386
  folderString
361
387
  ].join(""), {recursive: true});
362
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString,[
388
+ this.copyRecursiveSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString,[
363
389
  workspacePath,
364
390
  "/.workspace/resources/sounds/",
365
391
  folderString
366
- ].join(""), {recursive: true});
392
+ ].join(""));
393
+ // fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString,[
394
+ // workspacePath,
395
+ // "/.workspace/resources/sounds/",
396
+ // folderString
397
+ // ].join(""), {recursive: true});
367
398
  }
368
399
  }
369
400
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jtff/miztemplate-lib",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "JTFF mission template library",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -473,7 +473,8 @@ function injectScripts(jtffci, env_mission) {
473
473
  if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_radio_presets)) {
474
474
  // injection des preset radio
475
475
  fs.mkdirSync(workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true});
476
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
476
+ jtffci.mizlib.copyRecursiveSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre);
477
+ // fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
477
478
  console.log(destinationMizFilePath + ": injecting radio presets declared in resources/radios/" + missionObject.theatre);
478
479
  await jtffci.mizlib.injectRadioPresetsFromFolderIntoZipObject(mizObject, workspacePath + '/resources/radios/' + missionObject.theatre);
479
480
  }