Restore node_modules to exact state from cli.js.map extraction: - Move .ignored/ and .ignored_* files back to original package paths - Remove pnpm symlinks (replaced by real source-map directories) - Update .gitignore: only exclude /dist/, .pnpm/, .bin/, .ignored* dirs - All package dist/ folders are now preserved as part of source-map files After clone, run `pnpm install` to get pnpm-managed symlinks for building. The committed node_modules contains the original TypeScript/JS source files as bundled in cli.js.
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import {createWriteStream} from 'node:fs';
|
|
import {ChildProcess} from 'node:child_process';
|
|
import {isWritableStream} from 'is-stream';
|
|
|
|
const isExecaChildProcess = target => target instanceof ChildProcess && typeof target.then === 'function';
|
|
|
|
const pipeToTarget = (spawned, streamName, target) => {
|
|
if (typeof target === 'string') {
|
|
spawned[streamName].pipe(createWriteStream(target));
|
|
return spawned;
|
|
}
|
|
|
|
if (isWritableStream(target)) {
|
|
spawned[streamName].pipe(target);
|
|
return spawned;
|
|
}
|
|
|
|
if (!isExecaChildProcess(target)) {
|
|
throw new TypeError('The second argument must be a string, a stream or an Execa child process.');
|
|
}
|
|
|
|
if (!isWritableStream(target.stdin)) {
|
|
throw new TypeError('The target child process\'s stdin must be available.');
|
|
}
|
|
|
|
spawned[streamName].pipe(target.stdin);
|
|
return target;
|
|
};
|
|
|
|
export const addPipeMethods = spawned => {
|
|
if (spawned.stdout !== null) {
|
|
spawned.pipeStdout = pipeToTarget.bind(undefined, spawned, 'stdout');
|
|
}
|
|
|
|
if (spawned.stderr !== null) {
|
|
spawned.pipeStderr = pipeToTarget.bind(undefined, spawned, 'stderr');
|
|
}
|
|
|
|
if (spawned.all !== undefined) {
|
|
spawned.pipeAll = pipeToTarget.bind(undefined, spawned, 'all');
|
|
}
|
|
};
|