@wpmoo/odoo 0.8.65 → 0.8.66
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/dist/external-assets.js +29 -1
- package/package.json +1 -1
package/dist/external-assets.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cp, mkdir, mkdtemp, rm, stat, writeFile } from 'node:fs/promises';
|
|
1
|
+
import { cp, mkdir, mkdtemp, readdir, rm, stat, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
3
|
import { dirname, join, relative, resolve } from 'node:path';
|
|
4
4
|
import { realGit } from './git.js';
|
|
@@ -12,6 +12,14 @@ async function pathExists(path) {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
async function statIfExists(path) {
|
|
16
|
+
try {
|
|
17
|
+
return await stat(path);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
15
23
|
function expandHome(path) {
|
|
16
24
|
if (path === '~')
|
|
17
25
|
return process.env.HOME ?? path;
|
|
@@ -61,6 +69,25 @@ function isExcluded(relativePath, excludes) {
|
|
|
61
69
|
const normalized = relativePath.split('\\').join('/');
|
|
62
70
|
return excludes.some((pattern) => normalized === pattern || normalized.startsWith(`${pattern}/`));
|
|
63
71
|
}
|
|
72
|
+
async function removeDestinationTypeConflicts(sourcePath, destinationPath, excludes) {
|
|
73
|
+
async function visit(source) {
|
|
74
|
+
const rel = relative(sourcePath, source);
|
|
75
|
+
if (rel && isExcluded(rel, excludes))
|
|
76
|
+
return;
|
|
77
|
+
const sourceStat = await stat(source);
|
|
78
|
+
const destination = rel ? join(destinationPath, rel) : destinationPath;
|
|
79
|
+
const destinationStat = await statIfExists(destination);
|
|
80
|
+
if (destinationStat && sourceStat.isDirectory() !== destinationStat.isDirectory()) {
|
|
81
|
+
await rm(destination, { recursive: true, force: true });
|
|
82
|
+
}
|
|
83
|
+
if (!sourceStat.isDirectory()) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const entries = await readdir(source);
|
|
87
|
+
await Promise.all(entries.map((entry) => visit(join(source, entry))));
|
|
88
|
+
}
|
|
89
|
+
await visit(sourcePath);
|
|
90
|
+
}
|
|
64
91
|
async function copyDirectory(options, checkedOut) {
|
|
65
92
|
const selectedSourceSubdir = await selectSourceSubdir(options, checkedOut.root);
|
|
66
93
|
const sourcePath = selectedSourceSubdir ? join(checkedOut.root, selectedSourceSubdir) : checkedOut.root;
|
|
@@ -72,6 +99,7 @@ async function copyDirectory(options, checkedOut) {
|
|
|
72
99
|
}
|
|
73
100
|
const excludes = [...defaultExcludes, ...(options.exclude ?? [])];
|
|
74
101
|
await mkdir(destinationPath, { recursive: true });
|
|
102
|
+
await removeDestinationTypeConflicts(sourcePath, destinationPath, excludes);
|
|
75
103
|
await cp(sourcePath, destinationPath, {
|
|
76
104
|
recursive: true,
|
|
77
105
|
force: true,
|