Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zx

Package Overview
Dependencies
Maintainers
2
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zx - npm Package Compare versions

Comparing version 7.0.7 to 7.0.8-dev.905ec9f

build/deps.d.ts

28

build/cli.js

@@ -24,6 +24,9 @@ #!/usr/bin/env node

import { randomId } from './util.js';
import { installDeps, parseDeps } from './deps.js';
await (async function main() {
const globals = './globals.js';
await import(globals);
$.verbose = !argv.quiet;
if (argv.quiet) {
$.verbose = false;
}
if (typeof argv.shell === 'string') {

@@ -124,3 +127,7 @@ $.shell = argv.shell;

async function writeAndImport(script, filepath, origin = filepath) {
await fs.writeFile(filepath, script.toString());
const contents = script.toString();
await fs.writeFile(filepath, contents);
if (argv.install) {
await installDeps(parseDeps(contents), dirname(filepath));
}
let wait = importPath(filepath, origin);

@@ -231,11 +238,12 @@ await fs.rm(filepath);

${chalk.bold('Options')}
--quiet don't echo commands
--shell=<path> custom shell binary
--prefix=<command> prefix all commands
--interactive, -i start repl
--eval=<js>, -e evaluate script
--experimental enable new api proposals
--version, -v print current zx version
--help, -h print help
--quiet don't echo commands
--shell=<path> custom shell binary
--prefix=<command> prefix all commands
--interactive, -i start repl
--eval=<js>, -e evaluate script
--experimental enable new api proposals
--install parse and load script dependencies from the registry
--version, -v print current zx version
--help, -h print help
`);
}

@@ -41,2 +41,3 @@ /// <reference types="node" resolution-mode="require"/>

private _resolved;
private _halted;
private _piped;

@@ -46,13 +47,17 @@ _prerun: typeof noop;

_bind(cmd: string, from: string, resolve: Resolve, reject: Resolve, options: Options): void;
_run(): void;
run(): ProcessPromise;
get stdin(): Writable;
get stdout(): Readable;
get stderr(): Readable;
get exitCode(): Promise<any>;
get exitCode(): Promise<number | null>;
then<R = ProcessOutput, E = ProcessOutput>(onfulfilled?: ((value: ProcessOutput) => PromiseLike<R> | R) | undefined | null, onrejected?: ((reason: ProcessOutput) => PromiseLike<E> | E) | undefined | null): Promise<R | E>;
catch<T = ProcessOutput>(onrejected?: ((reason: ProcessOutput) => PromiseLike<T> | T) | undefined | null): Promise<ProcessOutput | T>;
pipe(dest: Writable | ProcessPromise): ProcessPromise;
kill(signal?: string): Promise<void>;
stdio(stdin: IO, stdout?: IO, stderr?: IO): this;
nothrow(): this;
quiet(): this;
timeout(d: Duration, signal?: string): this;
stdio(stdin: IO, stdout?: IO, stderr?: IO): ProcessPromise;
nothrow(): ProcessPromise;
quiet(): ProcessPromise;
timeout(d: Duration, signal?: string): ProcessPromise;
halt(): ProcessPromise;
get isHalted(): boolean;
}

@@ -59,0 +64,0 @@ export declare class ProcessOutput extends Error {

@@ -72,3 +72,4 @@ // Copyright 2021 Google LLC

promise._bind(cmd, from, resolve, reject, getStore());
setImmediate(() => promise._run()); // Postpone run to allow promise configuration.
// Postpone run to allow promise configuration.
setImmediate(() => promise.isHalted || promise.run());
return promise;

@@ -104,2 +105,3 @@ }, {

this._resolved = false;
this._halted = false;
this._piped = false;

@@ -116,6 +118,6 @@ this._prerun = noop;

}
_run() {
run() {
const $ = this._snapshot;
if (this.child)
return; // The _run() can be called from a few places.
return this; // The _run() can be called from a few places.
this._prerun(); // In case $1.pipe($2), the $2 returned, and on $2._run() invoke $1._run().

@@ -127,3 +129,3 @@ $.log({

});
this.child = spawn($.prefix + this._command, {
this.child = $.spawn($.prefix + this._command, {
cwd: $.cwd ?? $[processCwd],

@@ -180,6 +182,7 @@ shell: typeof $.shell === 'string' ? $.shell : true,

}
return this;
}
get stdin() {
this.stdio('pipe');
this._run();
this.run();
assert(this.child);

@@ -191,3 +194,3 @@ if (this.child.stdin == null)

get stdout() {
this._run();
this.run();
assert(this.child);

@@ -199,3 +202,3 @@ if (this.child.stdout == null)

get stderr() {
this._run();
this.run();
assert(this.child);

@@ -209,2 +212,11 @@ if (this.child.stderr == null)

}
then(onfulfilled, onrejected) {
if (this.isHalted && !this.child) {
throw new Error('The process is halted!');
}
return super.then(onfulfilled, onrejected);
}
catch(onrejected) {
return super.catch(onrejected);
}
pipe(dest) {

@@ -221,3 +233,3 @@ if (typeof dest == 'string')

dest.stdio('pipe');
dest._prerun = this._run.bind(this);
dest._prerun = this.run.bind(this);
dest._postrun = () => {

@@ -269,2 +281,9 @@ if (!dest.child)

}
halt() {
this._halted = true;
return this;
}
get isHalted() {
return this._halted;
}
}

@@ -271,0 +290,0 @@ export class ProcessOutput extends Error {

@@ -90,2 +90,3 @@ // Copyright 2021 Google LLC

clearInterval(id);
process.stderr.write(' '.repeat(process.stdout.columns - 1) + '\r');
}

@@ -92,0 +93,0 @@ return result;

@@ -26,3 +26,3 @@ // Copyright 2022 Google LLC

export function quote(arg) {
if (/^[a-z0-9/_.-]+$/i.test(arg) || arg === '') {
if (/^[a-z0-9/_.\-@:=]+$/i.test(arg) || arg === '') {
return arg;

@@ -29,0 +29,0 @@ }

{
"name": "zx",
"version": "7.0.7",
"version": "7.0.8-dev.905ec9f",
"description": "A tool for writing better scripts.",

@@ -55,3 +55,3 @@ "type": "module",

"@types/minimist": "^1.2.2",
"@types/node": "^17.0",
"@types/node": "^18.6.3",
"@types/ps-tree": "^1.1.2",

@@ -63,3 +63,3 @@ "@types/which": "^2.0.1",

"minimist": "^1.2.6",
"node-fetch": "^3.2.6",
"node-fetch": "3.2.8",
"ps-tree": "^1.2.0",

@@ -70,9 +70,9 @@ "which": "^2.0.2",

"devDependencies": {
"@stryker-mutator/core": "^6.0.2",
"c8": "^7.11.3",
"@stryker-mutator/core": "^6.1.2",
"c8": "^7.12.0",
"madge": "^5.0.1",
"prettier": "^2.7.0",
"tsd": "^0.21.0",
"typescript": "^4.8.0-dev.20220529",
"uvu": "^0.5.3"
"prettier": "^2.7.1",
"tsd": "^0.22.0",
"typescript": "^4.8.0-dev.20220729",
"uvu": "^0.5.6"
},

@@ -79,0 +79,0 @@ "publishConfig": {

@@ -410,2 +410,24 @@ # 🐚 zx

## CLI
| Flag | Description | Default |
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| `--quiet` | don't echo commands | `false` |
| `--shell=<path>` | custom shell binary | |
| `--prefix=<command>` | prefix all commands | |
| `--interactive, -i` | start repl | |
| `--eval=<js>, -e` | evaluate script | |
| `--experimental` | enable new api proposals | |
| `--install` | parse and load script dependencies from the registry. You can pass additional [params via env vars](https://docs.npmjs.com/cli/v8/using-npm/config) like `npm_config_registry=<url>` or `npm_config_userconfig=<path>`. | `false` |
| `--version, -v` | print current zx version | |
| `--help, -h` | print help | |
```bash
zx script.js
zx --help
zx --experimental <<'EOF'
await $`pwd`
EOF
```
## FAQ

@@ -412,0 +434,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc