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

clean-scripts

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clean-scripts - npm Package Compare versions

Comparing version 1.3.3 to 1.4.0

3

dist/core.d.ts

@@ -16,3 +16,4 @@ /// <reference types="node" />

script: string;
constructor(script: string);
processKey: string | undefined;
constructor(script: string, processKey?: string | undefined);
}

@@ -28,6 +28,7 @@ "use strict";

class Service {
constructor(script) {
constructor(script, processKey) {
this.script = script;
this.processKey = processKey;
}
}
exports.Service = Service;

@@ -42,4 +42,5 @@ "use strict";

}
const scriptProcesses = [];
async function execAsync(script) {
const serviceProcesses = [];
const context = {};
async function execAsync(script, processKey) {
return new Promise((resolve, reject) => {

@@ -57,3 +58,6 @@ const now = Date.now();

subProcess.stderr.pipe(process.stderr);
scriptProcesses.push(subProcess);
if (processKey) {
context[processKey] = subProcess;
serviceProcesses.push(subProcess);
}
});

@@ -95,3 +99,3 @@ }

const now = Date.now();
execAsync(script.script);
execAsync(script.script, script.processKey);
return [{ time: Date.now() - now, script: script.script }];

@@ -101,3 +105,3 @@ }

const now = Date.now();
await script();
await script(context);
return [{ time: Date.now() - now, script: "Custom Promise" }];

@@ -126,3 +130,3 @@ }

executeCommandLine().then(() => {
for (const subProcess of scriptProcesses) {
for (const subProcess of serviceProcesses) {
subProcess.kill("SIGINT");

@@ -133,3 +137,3 @@ }

printInConsole(error);
for (const subProcess of scriptProcesses) {
for (const subProcess of serviceProcesses) {
subProcess.kill("SIGINT");

@@ -136,0 +140,0 @@ }

{
"name": "clean-scripts",
"version": "1.3.3",
"version": "1.4.0",
"description": "A CLI tool to make scripts in package.json clean.",

@@ -5,0 +5,0 @@ "main": "dist/core.js",

@@ -88,3 +88,3 @@ [![Dependency Status](https://david-dm.org/plantain-00/clean-scripts.svg)](https://david-dm.org/plantain-00/clean-scripts)

the type of the function should be `() => Promise<void>`
the type of the function should be `(context: { [key: string]: any }) => Promise<void>`

@@ -104,2 +104,19 @@ ```js

The `context` can be used to transfer data between different scripts.
```js
module.exports = {
build: [
context => {
context.foo = 'abc'
return Promise.resolve()
},
context => {
console.log(context.foo) // 'abc'
return Promise.resolve()
}
]
}
```
##### child script

@@ -130,3 +147,4 @@

build: [
new Service('http-server')
new Service('http-server -p 8000'),
new Service('http-server', 'server2') // the child process can be accessed by `context.server2` later
]

@@ -136,3 +154,3 @@ }

All created processes / services will be killed after all scripts end, or any script errors.
All services will be killed after all scripts end, or any script errors.

@@ -139,0 +157,0 @@ ##### short-hand methods

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