первая лаба
This commit is contained in:
20
MasterOK/node_modules/sync-child-process/LICENSE
generated
vendored
Normal file
20
MasterOK/node_modules/sync-child-process/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2024, Google LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
63
MasterOK/node_modules/sync-child-process/README.md
generated
vendored
Normal file
63
MasterOK/node_modules/sync-child-process/README.md
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# `sync-child-process`
|
||||
|
||||
This package exposes a `SyncChildProcess` class that allows Node.js to run a
|
||||
subprocess synchronously *and* interactively.
|
||||
|
||||
[**API Docs**]
|
||||
|
||||
[**API Docs**]: https://sass.github.io/sync-child-process/classes/SyncChildProcess.html
|
||||
|
||||
## Usage
|
||||
|
||||
Use [`new SyncChildProcess()`] to start running a subprocess. This supports the
|
||||
same API as [`child_process.spawn()`] other than a few options. You can send
|
||||
input to the process using [`process.stdin`], and receive events from it
|
||||
(stdout, stderr, or exit) using [`process.next()`]. This implements [the
|
||||
iterator protocol], but *not* the iterable protocol because it's intrinsically
|
||||
stateful.
|
||||
|
||||
[`new SyncChildProcess()`]: https://sass.github.io/sync-child-process/classes/SyncChildProcess.html#constructor
|
||||
[`child_process.spawn()`]: https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
|
||||
[`process.stdin`]: https://sass.github.io/sync-child-process/classes/SyncChildProcess.html#stdin
|
||||
[`process.next()`]: https://sass.github.io/sync-child-process/classes/SyncChildProcess.html#next
|
||||
[the iterator protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol
|
||||
|
||||
```js
|
||||
import {SyncChildProcess} from 'sync-child-process';
|
||||
// or
|
||||
// const {SyncChildProcess} = require('sync-child-process');
|
||||
|
||||
const node = new SyncChildProcess('node', ['--interactive']);
|
||||
|
||||
for (;;) {
|
||||
if (node.next().value.data.toString().endsWith('> ')) break;
|
||||
}
|
||||
|
||||
node.stdin.write("41 * Math.pow(2, 5)\n");
|
||||
console.log((node.next().value.data.toString().split("\n")[0]));
|
||||
node.stdin.write(".exit\n");
|
||||
console.log(`Node exited with exit code ${node.next().value.code}`);
|
||||
```
|
||||
|
||||
## Why synchrony?
|
||||
|
||||
See [the `sync-message-port` documentation] for an explanation of why running
|
||||
code synchronously can be valuable even in an asynchronous ecosystem like
|
||||
Node.js
|
||||
|
||||
[the `sync-message-port` documentation]: https://github.com/sass/sync-message-port?tab=readme-ov-file#why-synchrony
|
||||
|
||||
### Why not `child_process.spawnSync()`?
|
||||
|
||||
Although Node's built-in [`child_process.spawnSync()`] function does run
|
||||
synchronously, it's not interactive. It only returns once the process has run to
|
||||
completion and exited, which means it's not suitable for any long-lived
|
||||
subprocess that interleaves sending and receiving data, such as when using the
|
||||
[embedded Sass protocol].
|
||||
|
||||
[`child_process.spawnSync()`]: https://nodejs.org/api/child_process.html#child_processspawnsynccommand-args-options
|
||||
[embedded Sass protocol]: https://github.com/sass/sass/blob/main/spec/embedded-protocol.md
|
||||
|
||||
---
|
||||
|
||||
Disclaimer: this is not an official Google product.
|
||||
55
MasterOK/node_modules/sync-child-process/dist/lib/event.d.ts
generated
vendored
Normal file
55
MasterOK/node_modules/sync-child-process/dist/lib/event.d.ts
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/** An event emitted by the child process. */
|
||||
export type Event = StdoutEvent | StderrEvent | ExitEvent;
|
||||
/** An event sent from the worker to the host. */
|
||||
export type InternalEvent = InternalStdoutEvent | InternalStderrEvent | ExitEvent | ErrorEvent;
|
||||
/** An event indicating that data has been emitted over stdout. */
|
||||
export interface StdoutEvent {
|
||||
type: 'stdout';
|
||||
data: Buffer;
|
||||
}
|
||||
/** An event indicating that data has been emitted over stderr. */
|
||||
export interface StderrEvent {
|
||||
type: 'stderr';
|
||||
data: Buffer;
|
||||
}
|
||||
/** An event indicating that process has exited. */
|
||||
export interface ExitEvent {
|
||||
type: 'exit';
|
||||
/**
|
||||
* The exit code. This will be `undefined` if the subprocess was killed via
|
||||
* signal.
|
||||
*/
|
||||
code?: number;
|
||||
/**
|
||||
* The signal that caused this process to exit. This will be `undefined` if
|
||||
* the subprocess exited normally.
|
||||
*/
|
||||
signal?: NodeJS.Signals;
|
||||
}
|
||||
/**
|
||||
* The stdout event sent from the worker to the host. The structured clone
|
||||
* algorithm automatically converts `Buffer`s sent through `MessagePort`s to
|
||||
* `Uint8Array`s.
|
||||
*/
|
||||
export interface InternalStdoutEvent {
|
||||
type: 'stdout';
|
||||
data: Buffer | Uint8Array;
|
||||
}
|
||||
/**
|
||||
* The stderr event sent from the worker to the host. The structured clone
|
||||
* algorithm automatically converts `Buffer`s sent through `MessagePort`s to
|
||||
* `Uint8Array`s.
|
||||
*/
|
||||
export interface InternalStderrEvent {
|
||||
type: 'stderr';
|
||||
data: Buffer | Uint8Array;
|
||||
}
|
||||
/**
|
||||
* An error occurred when starting or closing the child process. This is only
|
||||
* used internally; the host will throw the error rather than returning it to
|
||||
* the caller.
|
||||
*/
|
||||
export interface ErrorEvent {
|
||||
type: 'error';
|
||||
error: Error;
|
||||
}
|
||||
6
MasterOK/node_modules/sync-child-process/dist/lib/event.js
generated
vendored
Normal file
6
MasterOK/node_modules/sync-child-process/dist/lib/event.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
// Copyright 2021 Google LLC. Use of this source code is governed by an
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=event.js.map
|
||||
1
MasterOK/node_modules/sync-child-process/dist/lib/event.js.map
generated
vendored
Normal file
1
MasterOK/node_modules/sync-child-process/dist/lib/event.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../lib/event.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC"}
|
||||
52
MasterOK/node_modules/sync-child-process/dist/lib/index.d.ts
generated
vendored
Normal file
52
MasterOK/node_modules/sync-child-process/dist/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import * as stream from 'stream';
|
||||
import { ExitEvent, StderrEvent, StdoutEvent } from './event';
|
||||
export { ExitEvent, StderrEvent, StdoutEvent } from './event';
|
||||
/**
|
||||
* A child process that runs synchronously while also allowing the user to
|
||||
* interact with it before it shuts down.
|
||||
*/
|
||||
export declare class SyncChildProcess implements Iterator<StderrEvent | StdoutEvent, ExitEvent | undefined> {
|
||||
/** The port that communicates with the worker thread. */
|
||||
private readonly port;
|
||||
/** The worker in which the child process runs. */
|
||||
private readonly worker;
|
||||
/** The standard input stream to write to the process. */
|
||||
readonly stdin: stream.Writable;
|
||||
/** Creates a new synchronous process running `command` with `args`. */
|
||||
constructor(command: string, options?: Options);
|
||||
constructor(command: string, args: string[], options?: Options);
|
||||
/**
|
||||
* Blocks until the child process is ready to emit another event, then returns
|
||||
* that event. This will return an [IteratorReturnResult] with an [ExitEvent]
|
||||
* once when the process exits. If it's called again after that, it will
|
||||
* return `{done: true}` without a value.
|
||||
*
|
||||
* If there's an error running the child process, this will throw that error.
|
||||
*/
|
||||
next(): IteratorResult<StdoutEvent | StderrEvent, ExitEvent | undefined>;
|
||||
/**
|
||||
* Sends a signal (`SIGTERM` by default) to the child process.
|
||||
*
|
||||
* This has no effect if the process has already exited.
|
||||
*/
|
||||
kill(signal?: NodeJS.Signals | number): void;
|
||||
/** Closes down the worker thread and the stdin stream. */
|
||||
private close;
|
||||
}
|
||||
/**
|
||||
* A subset of the options for [`child_process.spawn()`].
|
||||
*
|
||||
* [`child_process.spawn()`]: https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
|
||||
*/
|
||||
export interface Options {
|
||||
cwd?: string;
|
||||
env?: Record<string, string>;
|
||||
argv0?: string;
|
||||
uid?: number;
|
||||
gid?: number;
|
||||
shell?: boolean | string;
|
||||
windowsVerbatimArguments?: boolean;
|
||||
windowsHide?: boolean;
|
||||
timeout?: number;
|
||||
killSignal?: string | number;
|
||||
}
|
||||
128
MasterOK/node_modules/sync-child-process/dist/lib/index.js
generated
vendored
Normal file
128
MasterOK/node_modules/sync-child-process/dist/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
// Copyright 2021 Google LLC. Use of this source code is governed by an
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SyncChildProcess = void 0;
|
||||
const fs = require("fs");
|
||||
const p = require("path");
|
||||
const stream = require("stream");
|
||||
const worker_threads_1 = require("worker_threads");
|
||||
const worker_threads = require("worker_threads");
|
||||
const sync_message_port_1 = require("sync-message-port");
|
||||
/** Whether {@link object} can't be transferred between threads, only cloned. */
|
||||
function isMarkedAsUntransferable(object) {
|
||||
// TODO: Remove this check when we no longer support Node v20 (after
|
||||
// 2026-04-30).
|
||||
return 'isMarkedAsUntransferable' in worker_threads
|
||||
? // TODO - DefinitelyTyped/DefinitelyTyped#71033: Remove this cast
|
||||
worker_threads.isMarkedAsUntransferable(object)
|
||||
: false;
|
||||
}
|
||||
/**
|
||||
* A child process that runs synchronously while also allowing the user to
|
||||
* interact with it before it shuts down.
|
||||
*/
|
||||
class SyncChildProcess {
|
||||
/** The port that communicates with the worker thread. */
|
||||
port;
|
||||
/** The worker in which the child process runs. */
|
||||
worker;
|
||||
/** The standard input stream to write to the process. */
|
||||
stdin;
|
||||
constructor(command, argsOrOptions, options) {
|
||||
let args;
|
||||
if (Array.isArray(argsOrOptions)) {
|
||||
args = argsOrOptions;
|
||||
}
|
||||
else {
|
||||
args = [];
|
||||
options = argsOrOptions;
|
||||
}
|
||||
const { port1, port2 } = sync_message_port_1.SyncMessagePort.createChannel();
|
||||
this.port = new sync_message_port_1.SyncMessagePort(port1);
|
||||
this.worker = spawnWorker(p.join(p.dirname(__filename), 'worker'), {
|
||||
workerData: { port: port2, command, args, options },
|
||||
transferList: [port2],
|
||||
});
|
||||
// The worker shouldn't emit any errors unless it breaks in development.
|
||||
this.worker.on('error', console.error);
|
||||
this.stdin = new stream.Writable({
|
||||
write: (chunk, encoding, callback) => {
|
||||
this.port.postMessage({
|
||||
type: 'stdin',
|
||||
data: chunk,
|
||||
}, isMarkedAsUntransferable(chunk.buffer) ? undefined : [chunk.buffer]);
|
||||
callback();
|
||||
},
|
||||
final: () => this.port.postMessage({ type: 'stdinClosed' }),
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Blocks until the child process is ready to emit another event, then returns
|
||||
* that event. This will return an [IteratorReturnResult] with an [ExitEvent]
|
||||
* once when the process exits. If it's called again after that, it will
|
||||
* return `{done: true}` without a value.
|
||||
*
|
||||
* If there's an error running the child process, this will throw that error.
|
||||
*/
|
||||
next() {
|
||||
if (this.stdin.destroyed)
|
||||
return { done: true, value: undefined };
|
||||
const message = this.port.receiveMessage();
|
||||
switch (message.type) {
|
||||
case 'stdout':
|
||||
return {
|
||||
value: { type: 'stdout', data: Buffer.from(message.data.buffer) },
|
||||
};
|
||||
case 'stderr':
|
||||
return {
|
||||
value: { type: 'stderr', data: Buffer.from(message.data.buffer) },
|
||||
};
|
||||
case 'error':
|
||||
this.close();
|
||||
throw message.error;
|
||||
case 'exit':
|
||||
this.close();
|
||||
return { done: true, value: message };
|
||||
}
|
||||
}
|
||||
// TODO(nex3): Add a non-blocking `yieldIfReady()` function that returns
|
||||
// `null` if the worker hasn't queued up an event.
|
||||
// TODO(nex3): Add a `yieldAsync()` function that returns a `Promise<Event>`.
|
||||
/**
|
||||
* Sends a signal (`SIGTERM` by default) to the child process.
|
||||
*
|
||||
* This has no effect if the process has already exited.
|
||||
*/
|
||||
kill(signal) {
|
||||
this.port.postMessage({ type: 'kill', signal });
|
||||
}
|
||||
/** Closes down the worker thread and the stdin stream. */
|
||||
close() {
|
||||
this.port.close();
|
||||
void this.worker.terminate();
|
||||
this.stdin.destroy();
|
||||
}
|
||||
}
|
||||
exports.SyncChildProcess = SyncChildProcess;
|
||||
/**
|
||||
* Spawns a worker for the given `fileWithoutExtension` in either a JS or TS
|
||||
* worker, depending on which file exists.
|
||||
*/
|
||||
function spawnWorker(fileWithoutExtension, options) {
|
||||
// The released version always spawns the JS worker. The TS worker is only
|
||||
// used for development.
|
||||
const jsFile = fileWithoutExtension + '.js';
|
||||
if (fs.existsSync(jsFile))
|
||||
return new worker_threads_1.Worker(jsFile, options);
|
||||
const tsFile = fileWithoutExtension + '.ts';
|
||||
if (fs.existsSync(tsFile)) {
|
||||
return new worker_threads_1.Worker(`
|
||||
require('ts-node').register();
|
||||
require(${JSON.stringify(tsFile)});
|
||||
`, { ...options, eval: true });
|
||||
}
|
||||
throw new Error(`Neither "${jsFile}" nor ".ts" exists.`);
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
MasterOK/node_modules/sync-child-process/dist/lib/index.js.map
generated
vendored
Normal file
1
MasterOK/node_modules/sync-child-process/dist/lib/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,yBAAyB;AACzB,0BAA0B;AAC1B,iCAAiC;AACjC,mDAAqD;AACrD,iDAAiD;AAEjD,yDAAkD;AAMlD,gFAAgF;AAChF,SAAS,wBAAwB,CAAC,MAAe;IAC/C,oEAAoE;IACpE,eAAe;IACf,OAAO,0BAA0B,IAAI,cAAc;QACjD,CAAC,CAAC,iEAAiE;YAChE,cAAc,CAAC,wBAAyD,CACvE,MAAM,CACP;QACH,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAa,gBAAgB;IAG3B,yDAAyD;IACxC,IAAI,CAAkB;IAEvC,kDAAkD;IACjC,MAAM,CAAS;IAEhC,yDAAyD;IAChD,KAAK,CAAkB;IAMhC,YACE,OAAe,EACf,aAAkC,EAClC,OAAiB;QAEjB,IAAI,IAAc,CAAC;QACnB,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;YACjC,IAAI,GAAG,aAAa,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,EAAE,CAAC;YACV,OAAO,GAAG,aAAa,CAAC;QAC1B,CAAC;QAED,MAAM,EAAC,KAAK,EAAE,KAAK,EAAC,GAAG,mCAAe,CAAC,aAAa,EAAE,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,IAAI,mCAAe,CAAC,KAAK,CAAC,CAAC;QAEvC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,EAAE;YACjE,UAAU,EAAE,EAAC,IAAI,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AAE,IAAI,EAAC,CACzB,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,qBAAqB,CAAC,CAAC;AAC3D,CAAC"}
|
||||
1
MasterOK/node_modules/sync-child-process/dist/lib/worker.d.ts
generated
vendored
Normal file
1
MasterOK/node_modules/sync-child-process/dist/lib/worker.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
51
MasterOK/node_modules/sync-child-process/dist/lib/worker.js
generated
vendored
Normal file
51
MasterOK/node_modules/sync-child-process/dist/lib/worker.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
// Copyright 2021 Google LLC. Use of this source code is governed by an
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const worker_threads_1 = require("worker_threads");
|
||||
const child_process_1 = require("child_process");
|
||||
const assert_1 = require("assert");
|
||||
const sync_message_port_1 = require("sync-message-port");
|
||||
const port = new sync_message_port_1.SyncMessagePort(worker_threads_1.workerData.port);
|
||||
/** A more type-safe way to call `port.postMesage()` */
|
||||
function emit(event, transferList) {
|
||||
port.postMessage(event, transferList);
|
||||
}
|
||||
const process = (0, child_process_1.spawn)(worker_threads_1.workerData.command, worker_threads_1.workerData.args, worker_threads_1.workerData.options);
|
||||
port.on('message', message => {
|
||||
if (message.type === 'stdin') {
|
||||
process.stdin.write(message.data);
|
||||
}
|
||||
else if (message.type === 'stdinClosed') {
|
||||
process.stdin.end();
|
||||
}
|
||||
else {
|
||||
assert_1.strict.equal(message.type, 'kill');
|
||||
process.kill(message.signal);
|
||||
}
|
||||
});
|
||||
process.stdout.on('data', data => {
|
||||
emit({ type: 'stdout', data }, [data.buffer]);
|
||||
});
|
||||
process.stderr.on('data', data => {
|
||||
emit({ type: 'stderr', data }, [data.buffer]);
|
||||
});
|
||||
process.on('error', error => {
|
||||
emit({ type: 'error', error });
|
||||
process.kill();
|
||||
worker_threads_1.parentPort.close();
|
||||
port.close();
|
||||
});
|
||||
process.on('exit', (code, signal) => {
|
||||
if (code !== null) {
|
||||
emit({ type: 'exit', code });
|
||||
}
|
||||
else {
|
||||
(0, assert_1.strict)(signal);
|
||||
emit({ type: 'exit', signal });
|
||||
}
|
||||
worker_threads_1.parentPort.close();
|
||||
port.close();
|
||||
});
|
||||
//# sourceMappingURL=worker.js.map
|
||||
1
MasterOK/node_modules/sync-child-process/dist/lib/worker.js.map
generated
vendored
Normal file
1
MasterOK/node_modules/sync-child-process/dist/lib/worker.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../lib/worker.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;AAEvC,mDAKwB;AACxB,iDAA8D;AAC9D,mCAAwC;AAExC,yDAAkD;AAIlD,MAAM,IAAI,GAAG,IAAI,mCAAe,CAAC,2BAAU,CAAC,IAAmB,CAAC,CAAC;AAEjE,uDAAuD;AACvD,SAAS,IAAI,CAAC,KAAoB,EAAE,YAAiC;IACnE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,OAAO,GAAG,IAAA,qBAAK,EACnB,2BAAU,CAAC,OAAiB,EAC5B,2BAAU,CAAC,IAAgB,EAC3B,2BAAU,CAAC,OAA+C,CAC3D,CAAC;AAEF,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE;IAC3B,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAc,CAAC,CAAC;IAC9C,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC1C,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;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E,CAAC;IACpB,IAAI,CAAC,KAAK,EAAE,CAAC;AACf,CAAC,CAAC,CAAC"}
|
||||
1
MasterOK/node_modules/sync-child-process/dist/tsconfig.build.tsbuildinfo
generated
vendored
Normal file
1
MasterOK/node_modules/sync-child-process/dist/tsconfig.build.tsbuildinfo
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
44
MasterOK/node_modules/sync-child-process/package.json
generated
vendored
Normal file
44
MasterOK/node_modules/sync-child-process/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "sync-child-process",
|
||||
"version": "1.0.2",
|
||||
"description": "Run a subprocess synchronously and interactively in Node.js",
|
||||
"repository": "sass/sync-child-process",
|
||||
"author": "Google Inc.",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"default": "./dist/lib/index.js"
|
||||
},
|
||||
"main": "dist/lib/index.js",
|
||||
"types": "dist/lib/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"check": "npm-run-all check:gts check:tsc",
|
||||
"check:gts": "gts check",
|
||||
"check:tsc": "tsc --noEmit",
|
||||
"clean": "gts clean",
|
||||
"compile": "tsc -p tsconfig.build.json",
|
||||
"doc": "typedoc lib/index.ts",
|
||||
"fix": "gts fix",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.4.0",
|
||||
"@types/node": "^22.0.0",
|
||||
"gts": "^6.0.2",
|
||||
"jest": "^29.4.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"ts-jest": "^29.0.5",
|
||||
"ts-node": "^10.2.1",
|
||||
"typedoc": "^0.26.11",
|
||||
"typescript": "^5.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"sync-message-port": "^1.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user