Socket
Socket
Sign inDemoInstall

clear-path

Package Overview
Dependencies
68
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.2.0

63

bin/clear-path.js

@@ -21,2 +21,33 @@ #!/usr/bin/env node

const displayError = ( title ) => {
info( chalk.red( ">" ), chalk.bold.red(title) );
info( chalk.gray( "> read https://github.com/vkiss/clear-path/blob/main/README.md#configuration to learn how to configure clear-path.js" ) );
}
const getRoutine = ( args ) => {
for ( const arg of args ) {
if ( arg.split("=")[0] === "--routine" ) {
return arg.split("=")[1];
}
}
return undefined;
}
const clearPathArrayOrString = ( pathsToDelete ) => {
if ( typeof( pathsToDelete ) === "string" ) {
clearPath( pathsToDelete );
return;
}
if ( Array.isArray( pathsToDelete ) ) {
for ( const path of pathsToDelete ) {
clearPath(path)
}
return;
}
return displayError( "wrong configuration" );
}
const runScript = () => {

@@ -31,16 +62,30 @@ // Script start message

if ( result === null ) {
info( chalk.red( ">" ), chalk.bold.red("configuration missing") );
info( chalk.gray( "> read https://github.com/vkiss/clear-path/blob/main/README.md#configuration to learn how to configure clear-path.js" ) );
return;
return displayError( "configuration missing" );
}
const pathsToDelete = filterConfig( result.config );
if ( typeof( pathsToDelete ) === "string" ) {
clearPath( pathsToDelete );
return;
if ( pathsToDelete.routine ) {
const args = process.argv.slice(2);
const argRoutine = getRoutine(args);
if ( argRoutine ) {
const routineToRun = pathsToDelete.routine[argRoutine];
if ( routineToRun ) {
return clearPathArrayOrString( routineToRun );
}
if ( pathsToDelete.routine.default ) {
return clearPathArrayOrString( pathsToDelete.routine.default );
}
return displayError( `routine '${argRoutine}' not found` );
}
return displayError( "missing routine parameter" );
}
for ( const path of pathsToDelete ) {
clearPath(path)
}
clearPathArrayOrString( pathsToDelete );
} )

@@ -47,0 +92,0 @@ .catch( ( error ) => {

10

package.json
{
"name": "clear-path",
"version": "1.1.2",
"version": "1.2.0",
"description": "A node library for deleteing a path if exists using del",

@@ -10,3 +10,3 @@ "license": "MIT",

},
"author": "Vinicius Kiss <contato@vkiss.com.br>",
"author": "Vinicius Kiss <contato@vkiss.com.br> (https://www.vkiss.com.br/)",
"bin": "./bin/clear-path.js",

@@ -37,3 +37,7 @@ "main": "./lib/index.js",

},
"clearpath": "dist"
"clearpath": {
"routine": {
"teste": "dist"
}
}
}

@@ -52,2 +52,37 @@ # clear-path

clearPath("dist");
```
```
## Multiple clear-path routines
### Example: package.json
Chose either one of the configurations samples below.
```json
# package.json
{
"scripts": {
"clean": "clear-path --routine=all",
"clean:dist": "clear-path --routine=dist"
},
"clearpath": {
"routine": {
"all": [
"dist",
"public"
],
"dist": "dist",
}
}
}
```
### Example: clearpath.rc
```yml
routine:
all:
dist
public
dist: dist
```
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc