Socket
Socket
Sign inDemoInstall

organize-pkg

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.0

7

index.js

@@ -17,6 +17,7 @@ #!/usr/bin/env node

function organizePackageJson(){const rootPkgJsonPath="./package.json";let pkgJson;try{pkgJson=utils.readJson(rootPkgJsonPath);}catch(e){console.error(e);return;}
if(pkgJson){const keys=params.keys;if(isInvalidValue(keys,`ERROR: "-keys" parameter must be required`)){return;}
if(pkgJson){const keys=params.keys||[];const isProd=params.prod;if(!isProd&&isInvalidValue(keys,`ERROR: "-keys" parameter must be required`)){return;}
let dest=params.out;if(isInvalidValue(dest,`ERROR: "-out" parameter must be required`)){return;}
keys.forEach(key=>delete pkgJson[key]);if(!/\.json$/.test(dest)){const last=[...dest].pop();dest=(last==="/"||last==="\\")?dest+"package.json":`${dest}/package.json`}
utils.writeTextUTF8(JSON.stringify(pkgJson,null,2),dest);}else{help();}}
const needless=isProd?["scripts","devDependencies"]:[];const actulaKeys=Array.isArray(keys)?keys:[keys];if(isProd){Object.keys(pkgJson).forEach(key=>{/^\/\//.test(key)&&delete pkgJson[key];});}
actulaKeys.concat(needless).forEach(key=>{delete pkgJson[key];});if(!/\.json$/.test(dest)){const last=[...dest].pop();dest=(last==="/"||last==="\\")?dest+"package.json":`${dest}/package.json`}
utils.writeTextUTF8(JSON.stringify(pkgJson,null,2),dest);}else{help(`ERROR: package.json not found`);}}
organizePackageJson();
{
"name": "organize-pkg",
"description": "very simple package.json organizer",
"version": "1.1.0",
"version": "1.2.0",
"bin": "index.js",

@@ -6,0 +6,0 @@ "files": [

@@ -37,2 +37,15 @@ # organize package json (organize-pkg) ![MIT](https://img.shields.io/badge/license-MIT-brightgreen)

## If you don't need to run a script such as "postinstall"
when installing the desired module with `(yarn|npm) install`,
specify `"-prod"` option to specify properties such as `"scripts"`, `"devDependencies"`, `"//<any text>?"`. Can be deleted.
>In that case, the value of `"-keys"` option will be optional, and if it is specified it will be merged
```
organize-pkg -prod -out ./dist [-keys "defs"]
```
## License

@@ -39,0 +52,0 @@

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