update
This commit is contained in:
@@ -6,7 +6,7 @@ import { getHash } from '@/uitls/hash.ts';
|
|||||||
import glob from 'fast-glob';
|
import glob from 'fast-glob';
|
||||||
import { isMatch } from 'micromatch';
|
import { isMatch } from 'micromatch';
|
||||||
import { logger } from '@/module/logger.ts';
|
import { logger } from '@/module/logger.ts';
|
||||||
|
import { normalizeScriptPath } from "@/uitls/file.ts";
|
||||||
export type SyncOptions = {
|
export type SyncOptions = {
|
||||||
dir?: string;
|
dir?: string;
|
||||||
configFilename?: string;
|
configFilename?: string;
|
||||||
@@ -70,7 +70,7 @@ export class SyncBase {
|
|||||||
const set = new Set(defaultIgnore);
|
const set = new Set(defaultIgnore);
|
||||||
return new Array(...set);
|
return new Array(...set);
|
||||||
}
|
}
|
||||||
getMatchList(opts?: { matchList?: string[]; ignore: string[]; matchObjectList?: { path: string; [key: string]: any }[] }) {
|
getMatchList(opts?: { matchList?: string[]; ignore: string[]; matchObjectList?: { path: string;[key: string]: any }[] }) {
|
||||||
const { matchList = [], ignore = [], matchObjectList = [] } = opts || {};
|
const { matchList = [], ignore = [], matchObjectList = [] } = opts || {};
|
||||||
const _ignore = this.getIngore(ignore);
|
const _ignore = this.getIngore(ignore);
|
||||||
const _matchList = matchList.filter((file) => !isMatch(file, _ignore));
|
const _matchList = matchList.filter((file) => !isMatch(file, _ignore));
|
||||||
@@ -175,8 +175,9 @@ export class SyncBase {
|
|||||||
const replaceKeys = Object.keys(replace);
|
const replaceKeys = Object.keys(replace);
|
||||||
let newKey = key;
|
let newKey = key;
|
||||||
for (let replaceKey of replaceKeys) {
|
for (let replaceKey of replaceKeys) {
|
||||||
if (newKey.startsWith(replaceKey)) {
|
const _replaceKey = normalizeScriptPath(replaceKey);
|
||||||
newKey = key.replace(replaceKey, replace[replaceKey]);
|
if (newKey.startsWith(_replaceKey)) {
|
||||||
|
newKey = key.replace(_replaceKey, replace[replaceKey]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const pathname = path.join(_registryURL.pathname, newKey);
|
const pathname = path.join(_registryURL.pathname, newKey);
|
||||||
|
|||||||
@@ -26,3 +26,10 @@ export const pathExists = (path: string, type?: 'file' | 'directory') => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
export const normalizeScriptPath = (scriptPath: string): string => {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
// 在 Windows 上,将反斜杠转换为正斜杠,PM2 更好地支持正斜杠
|
||||||
|
return scriptPath.replace(/\\/g, '/');
|
||||||
|
}
|
||||||
|
return scriptPath;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user