Make script delegation work on windows
This commit is contained in:
parent
2542c38c9b
commit
25d31463f4
@ -8,7 +8,7 @@ import {
|
|||||||
ApiVersion
|
ApiVersion
|
||||||
} from "./customHandler";
|
} from "./customHandler";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { dirname as pathDirname } from "path";
|
import { sep as pathSep } from "path";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
|
||||||
assert<Equals<ApiVersion, "v1">>();
|
assert<Equals<ApiVersion, "v1">>();
|
||||||
@ -19,7 +19,35 @@ export function maybeDelegateCommandToCustomHandler(params: {
|
|||||||
}): { hasBeenHandled: boolean } {
|
}): { hasBeenHandled: boolean } {
|
||||||
const { commandName, buildContext } = params;
|
const { commandName, buildContext } = params;
|
||||||
|
|
||||||
if (!fs.readdirSync(pathDirname(process.argv[1])).includes(BIN_NAME)) {
|
const nodeModulesBinDirPath = (() => {
|
||||||
|
const binPath = process.argv[1];
|
||||||
|
|
||||||
|
const segments: string[] = [".bin"];
|
||||||
|
|
||||||
|
let foundNodeModules = false;
|
||||||
|
|
||||||
|
for (const segment of binPath.split(pathSep).reverse()) {
|
||||||
|
skip_segment: {
|
||||||
|
if (foundNodeModules) {
|
||||||
|
break skip_segment;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (segment === "node_modules") {
|
||||||
|
foundNodeModules = true;
|
||||||
|
break skip_segment;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
segments.unshift(segment);
|
||||||
|
}
|
||||||
|
|
||||||
|
return segments.join(pathSep);
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (!fs.readdirSync(nodeModulesBinDirPath).includes(BIN_NAME)) {
|
||||||
|
console.log(`Custom handler not found`);
|
||||||
return { hasBeenHandled: false };
|
return { hasBeenHandled: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user