New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zx

Package Overview
Dependencies
Maintainers
2
Versions
166
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.1.0-dev.96d40f9 to 7.1.0-dev.b684619

31

build/cli.js

@@ -99,12 +99,5 @@ #!/usr/bin/env node

}
let filepath;
if (firstArg.startsWith('/')) {
filepath = firstArg;
}
else if (firstArg.startsWith('file:///')) {
filepath = url.fileURLToPath(firstArg);
}
else {
filepath = resolve(firstArg);
}
const filepath = firstArg.startsWith('file:///')
? url.fileURLToPath(firstArg)
: resolve(firstArg);
await importPath(filepath);

@@ -161,11 +154,11 @@ })().catch((err) => {

async function importPath(filepath, origin = filepath) {
let ext = extname(filepath);
const ext = extname(filepath);
if (ext === '') {
let tmpFilename = fs.existsSync(`${filepath}.mjs`)
const tmpFilename = fs.existsSync(`${filepath}.mjs`)
? `${basename(filepath)}-${randomId()}.mjs`
: `${basename(filepath)}.mjs`;
return await writeAndImport(await fs.readFile(filepath), join(dirname(filepath), tmpFilename), origin);
return writeAndImport(await fs.readFile(filepath), join(dirname(filepath), tmpFilename), origin);
}
if (ext === '.md') {
return await writeAndImport(transformMarkdown(await fs.readFile(filepath)), join(dirname(filepath), basename(filepath) + '.mjs'), origin);
return writeAndImport(transformMarkdown(await fs.readFile(filepath)), join(dirname(filepath), basename(filepath) + '.mjs'), origin);
}

@@ -177,5 +170,5 @@ if (argv.install) {

}
let __filename = resolve(origin);
let __dirname = dirname(__filename);
let require = createRequire(origin);
const __filename = resolve(origin);
const __dirname = dirname(__filename);
const require = createRequire(origin);
Object.assign(global, { __filename, __dirname, require });

@@ -185,4 +178,4 @@ await import(url.pathToFileURL(filepath).toString());

function transformMarkdown(buf) {
let source = buf.toString();
let output = [];
const source = buf.toString();
const output = [];
let state = 'root';

@@ -189,0 +182,0 @@ let prevLineIsEmpty = true;

@@ -59,3 +59,3 @@ // Copyright 2021 Google LLC

let resolve, reject;
let promise = new ProcessPromise((...args) => ([resolve, reject] = args));
const promise = new ProcessPromise((...args) => ([resolve, reject] = args));
let cmd = pieces[0], i = 0;

@@ -62,0 +62,0 @@ while (i < args.length) {

@@ -23,5 +23,63 @@ // Copyright 2021 Google LLC

}
const builtinsRe = /^(_http_agent|_http_client|_http_common|_http_incoming|_http_outgoing|_http_server|_stream_duplex|_stream_passthrough|_stream_readable|_stream_transform|_stream_wrap|_stream_writable|_tls_common|_tls_wrap|assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|diagnostics_channel|dns|domain|events|fs|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|trace_events|tty|url|util|v8|vm|wasi|worker_threads|zlib)$/;
// https://github.com/nodejs/node/blob/5fad0b93667ffc6e4def52996b9529ac99b26319/test/parallel/test-internal-module-require.js
// + wasi https://nodejs.org/api/wasi.html
const builtins = new Set([
'_http_agent',
'_http_client',
'_http_common',
'_http_incoming',
'_http_outgoing',
'_http_server',
'_stream_duplex',
'_stream_passthrough',
'_stream_readable',
'_stream_transform',
'_stream_wrap',
'_stream_writable',
'_tls_common',
'_tls_wrap',
'assert',
'async_hooks',
'buffer',
'child_process',
'cluster',
'console',
'constants',
'crypto',
'dgram',
'dns',
'domain',
'events',
'fs',
'http',
'http2',
'https',
'inspector',
'module',
'net',
'os',
'path',
'perf_hooks',
'process',
'punycode',
'querystring',
'readline',
'repl',
'stream',
'string_decoder',
'sys',
'timers',
'tls',
'trace_events',
'tty',
'url',
'util',
'v8',
'vm',
'wasi',
'worker_threads',
'zlib',
]);
export function parseDeps(content) {
const re = /(?:\sfrom\s+|[\s(:\[](?:import|require)\s*\()["']((?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*)[/a-z0-9-._~]*["'](?:\s*;?\s*(?:\/\*|\/\/)\s*([a-z0-9-._~^*]+))?/g;
const re = /(?:\sfrom\s+|(?:[\s(\[{:;=+\-*|/~^%&,]|\.{3}|^)(?:import\s*\(?|require\s*\())["']((?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*)[/a-z0-9-._~]*["'](?:\)?[\s;,]*(?:\/\*|\/\/)\s*([a-z0-9-._~^*]+))?/g;
const deps = {};

@@ -31,3 +89,3 @@ let m;

m = re.exec(content.toString());
if (m && !builtinsRe.test(m[1])) {
if (m && !builtins.has(m[1])) {
deps[m[1]] = m[2] || 'latest';

@@ -34,0 +92,0 @@ }

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

let msg;
let lastIdx = pieces.length - 1;
const lastIdx = pieces.length - 1;
if (Array.isArray(pieces) &&

@@ -49,0 +49,0 @@ pieces.every(isString) &&

{
"name": "zx",
"version": "7.1.0-dev.96d40f9",
"version": "7.1.0-dev.b684619",
"description": "A tool for writing better scripts.",

@@ -5,0 +5,0 @@ "type": "module",

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