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

nmc

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nmc - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

50

bin/nmc.js
#! /usr/bin/env node
const fs = require('fs/promises');
const path = require('path');
const fs = require('fs/promises')
const path = require('path')
const search = async (name, base, options) => {
base = base ? path.normalize(base) : process.cwd();
let dir = await fs.readdir(base);
let results = [];
base = base ? path.normalize(base) : process.cwd()
let dir = await fs.readdir(base)
let results = []
for (let i = 0; i < dir.length; i++) {
let currentPath = path.join(base, dir[i]);
let currentPath = path.join(base, dir[i])
if ((await fs.stat(currentPath)).isDirectory()) {
if (dir[i] === name) {
results.push(currentPath);
results.push(currentPath)
} else {
results.push(...(await search(name, currentPath, options)));
results.push(...(await search(name, currentPath, options)))
}

@@ -21,28 +21,28 @@ }

return results;
};
return results
}
const clean = (dir) => {
return fs.rmdir(dir, { recursive: true });
};
return fs.rm(dir, { recursive: true })
}
const nmc = () => {
let options = {};
let args = process.argv.slice(2);
if (args.includes('-l') || args.includes('--log')) options.log = true;
let options = {}
let args = process.argv.slice(2)
if (args.includes('-l') || args.includes('--log')) options.log = true
if (options.log) console.log('\x1b[32m', 'Searching...', '\x1b[0m');
if (options.log) console.log('\x1b[32m', 'Searching...', '\x1b[0m')
search('node_modules').then((results) => {
if (results.length) {
if (options.log) console.log('Directories found:', results);
if (options.log) console.log('Directories found:', results)
results.forEach((res) => {
clean(res);
});
clean(res)
})
} else {
console.error('\x1b[31m', 'No node_modules directories found', '\x1b[0m');
process.exit(1);
console.error('\x1b[31m', 'No node_modules directories found', '\x1b[0m')
process.exit(1)
}
console.log('\x1b[32m', 'nmc done!', '\x1b[0m');
});
};
console.log('\x1b[32m', 'nmc done!', '\x1b[0m')
})
}
nmc();
nmc()
{
"name": "nmc",
"version": "0.0.2",
"description": "node modules cleaner",
"main": "bin/nmc.js",
"bin": {
"nmc": "bin/nmc.js"
},
"homepage": "https://github.com/origeva/nmc",
"repository": {
"type": "git",
"url": "https://github.com/origeva/nmc"
},
"scripts": {
"start": "node bin/nmc.js"
},
"keywords": [
"node",
"node_modules",
"modules",
"cli",
"cleaner"
],
"author": "Ori Geva",
"license": "MIT"
"name": "nmc",
"version": "0.0.3",
"description": "node modules cleaner",
"main": "bin/nmc.js",
"bin": {
"nmc": "bin/nmc.js"
},
"homepage": "https://github.com/origeva/nmc",
"repository": {
"type": "git",
"url": "https://github.com/origeva/nmc"
},
"scripts": {
"start": "node bin/nmc.js"
},
"keywords": [
"node",
"node_modules",
"modules",
"cli",
"cleaner"
],
"author": "Ori Geva",
"license": "MIT"
}
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