@9of9solutions/replikator 1.0.13 → 1.0.14
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/main.js +33 -2
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -12,6 +12,20 @@ async function getVersion() {
|
|
|
12
12
|
const pkg = await fs.readJson(pkgPath, 'utf8');
|
|
13
13
|
return pkg.version;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
async function getReplicatedFileHeader(path) {
|
|
17
|
+
return `/******************************************************
|
|
18
|
+
* RPK / Replikator CLI tool / version ${await getVersion()}
|
|
19
|
+
*
|
|
20
|
+
* File replicated by Replicator
|
|
21
|
+
* DO NOT EDIT
|
|
22
|
+
*
|
|
23
|
+
* Edit at '${path}'
|
|
24
|
+
*
|
|
25
|
+
******************************************************/\n`
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
15
29
|
//We save configuration in root package.json
|
|
16
30
|
const PACKAGE_JSON_ROOT_PATH = path.resolve(projectRoot, 'package.json');
|
|
17
31
|
const SHARED_PATH = 'shared';
|
|
@@ -227,8 +241,17 @@ async function main() {
|
|
|
227
241
|
|
|
228
242
|
await Promise.all(
|
|
229
243
|
targets.map(dest =>
|
|
230
|
-
fs.ensureDir(dest).then(() =>
|
|
231
|
-
fs.copy(src, dest, { overwrite: true })
|
|
244
|
+
fs.ensureDir(dest).then(async () => {
|
|
245
|
+
await fs.copy(src, dest, { overwrite: true })
|
|
246
|
+
if((await fs.lstat(src)).isFile()) {
|
|
247
|
+
const data = await fs.readFile(src);
|
|
248
|
+
const fd = await fs.open(dest, 'w+');
|
|
249
|
+
const buffer = Buffer.from(await getReplicatedFileHeader(src));
|
|
250
|
+
await fs.write(fd, buffer, 0, buffer.length, 0);
|
|
251
|
+
await fs.write(fd, data, 0, data.length, buffer.length);
|
|
252
|
+
await fs.chmod(dest, 0o444)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
232
255
|
)
|
|
233
256
|
)
|
|
234
257
|
);
|
|
@@ -255,6 +278,14 @@ async function syncFile(event, filePath, srcDir, targets) {
|
|
|
255
278
|
} else {
|
|
256
279
|
await fs.ensureDir(path.dirname(destPath));
|
|
257
280
|
await fs.copy(filePath, destPath, { overwrite: true });
|
|
281
|
+
if((await fs.lstat(filePath)).isFile()) {
|
|
282
|
+
const data = await fs.readFile(filePath);
|
|
283
|
+
const fd = await fs.open(destPath, 'w+');
|
|
284
|
+
const buffer = Buffer.from(await getReplicatedFileHeader(filePath));
|
|
285
|
+
await fs.write(fd, buffer, 0, buffer.length, 0);
|
|
286
|
+
await fs.write(fd, data, 0, data.length, buffer.length);
|
|
287
|
+
await fs.chmod(destPath, 0o444)
|
|
288
|
+
}
|
|
258
289
|
console.log(`${event === 'add' ? 'Added' : 'Updated'}: ${rel}`);
|
|
259
290
|
}
|
|
260
291
|
}));
|