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

@tauri-apps/plugin-shell

Package Overview
Dependencies
Maintainers
5
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tauri-apps/plugin-shell - npm Package Compare versions

Comparing version 2.0.0-beta.3 to 2.0.0-beta.4

2

dist-js/index.d.ts

@@ -237,4 +237,2 @@ /**

execute(): Promise<ChildProcess<O>>;
/** @ignore */
private collectOutput;
}

@@ -241,0 +239,0 @@ /**

82

dist-js/index.js

@@ -66,29 +66,4 @@ import { invoke, Channel } from '@tauri-apps/api/core';

/**
* Spawns a process.
*
* @ignore
* @param program The name of the scoped command.
* @param onEventHandler Event handler.
* @param args Program arguments.
* @param options Configuration for the process spawn.
* @returns A promise resolving to the process id.
*
* @since 2.0.0
*/
async function execute(onEventHandler, program, args = [], options) {
if (typeof args === "object") {
Object.freeze(args);
}
const onEvent = new Channel();
onEvent.onmessage = onEventHandler;
return await invoke("plugin:shell|execute", {
program,
args,
options,
onEvent,
});
}
/**
* @since 2.0.0
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -382,3 +357,10 @@ class EventEmitter {

async spawn() {
return await execute((event) => {
const program = this.program;
const args = this.args;
const options = this.options;
if (typeof args === "object") {
Object.freeze(args);
}
const onEvent = new Channel();
onEvent.onmessage = (event) => {
switch (event.event) {

@@ -398,3 +380,9 @@ case "Error":

}
}, this.program, this.args, this.options).then((pid) => new Child(pid));
};
return await invoke("plugin:shell|spawn", {
program,
args,
options,
onEvent,
}).then((pid) => new Child(pid));
}

@@ -418,34 +406,14 @@ /**

async execute() {
return await new Promise((resolve, reject) => {
this.on("error", reject);
const stdout = [];
const stderr = [];
this.stdout.on("data", (line) => {
stdout.push(line);
});
this.stderr.on("data", (line) => {
stderr.push(line);
});
this.on("close", (payload) => {
resolve({
code: payload.code,
signal: payload.signal,
stdout: this.collectOutput(stdout),
stderr: this.collectOutput(stderr),
});
});
this.spawn().catch(reject);
const program = this.program;
const args = this.args;
const options = this.options;
if (typeof args === "object") {
Object.freeze(args);
}
return await invoke("plugin:shell|execute", {
program,
args,
options,
});
}
/** @ignore */
collectOutput(events) {
if (this.options.encoding === "raw") {
return events.reduce((p, c) => {
return new Uint8Array([...p, ...c, 10]);
}, new Uint8Array());
}
else {
return events.join("\n");
}
}
}

@@ -452,0 +420,0 @@ /**

{
"name": "@tauri-apps/plugin-shell",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"license": "MIT or APACHE-2.0",

@@ -5,0 +5,0 @@ "authors": [

Sorry, the diff of this file is not supported yet

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