fix(M06-R): 修复静态检查路径兼容
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
const root = new URL('..', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1');
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
||||||
const read = (path) => readFileSync(join(root, path), 'utf8');
|
const read = (path) => readFileSync(join(root, path), 'utf8');
|
||||||
|
|
||||||
const packageJson = JSON.parse(read('admin/package.json'));
|
const packageJson = JSON.parse(read('admin/package.json'));
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
const root = new URL('..', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1');
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
||||||
const read = (path) => readFileSync(join(root, path), 'utf8');
|
const read = (path) => readFileSync(join(root, path), 'utf8');
|
||||||
|
|
||||||
const app = read('admin/src/App.vue');
|
const app = read('admin/src/App.vue');
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
const root = new URL('..', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1');
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
||||||
const read = (path) => readFileSync(join(root, path), 'utf8');
|
const read = (path) => readFileSync(join(root, path), 'utf8');
|
||||||
|
|
||||||
const appJson = JSON.parse(read('miniapp/app.json'));
|
const appJson = JSON.parse(read('miniapp/app.json'));
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
const root = new URL('..', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1');
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
||||||
const read = (path) => readFileSync(join(root, path), 'utf8');
|
const read = (path) => readFileSync(join(root, path), 'utf8');
|
||||||
|
|
||||||
const appJson = JSON.parse(read('miniapp/app.json'));
|
const appJson = JSON.parse(read('miniapp/app.json'));
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import {
|
||||||
|
cpSync,
|
||||||
|
mkdtempSync,
|
||||||
|
mkdirSync,
|
||||||
|
rmSync
|
||||||
|
} from 'node:fs';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { basename, join } from 'node:path';
|
||||||
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
||||||
|
const temporaryRoot = mkdtempSync(join(tmpdir(), '棋牌 路径回归 '));
|
||||||
|
const checks = [
|
||||||
|
'check-miniapp-m08-a.mjs',
|
||||||
|
'check-miniapp-m08-c.mjs',
|
||||||
|
'check-admin-m08-b.mjs',
|
||||||
|
'check-admin-m08-d.mjs'
|
||||||
|
];
|
||||||
|
|
||||||
|
const copySource = (name) => {
|
||||||
|
const source = join(root, name);
|
||||||
|
const target = join(temporaryRoot, name);
|
||||||
|
cpSync(source, target, {
|
||||||
|
recursive: true,
|
||||||
|
filter: (entry) => {
|
||||||
|
const part = basename(entry);
|
||||||
|
return part !== 'node_modules' && part !== 'dist';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
copySource('admin');
|
||||||
|
copySource('backend');
|
||||||
|
copySource('database');
|
||||||
|
copySource('miniapp');
|
||||||
|
mkdirSync(join(temporaryRoot, 'scripts'));
|
||||||
|
for (const check of checks) {
|
||||||
|
cpSync(join(root, 'scripts', check), join(temporaryRoot, 'scripts', check));
|
||||||
|
const result = spawnSync(process.execPath, [join(temporaryRoot, 'scripts', check)], {
|
||||||
|
cwd: temporaryRoot,
|
||||||
|
encoding: 'utf8'
|
||||||
|
});
|
||||||
|
assert.equal(
|
||||||
|
result.status,
|
||||||
|
0,
|
||||||
|
`${check} failed in ${temporaryRoot}\n${result.stdout}${result.stderr}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
console.log(`PASS: four static checks support a Unicode/space repository path (${temporaryRoot}).`);
|
||||||
|
} finally {
|
||||||
|
rmSync(temporaryRoot, { recursive: true, force: true });
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user