fuck-npm
Advanced tools
Comparing version 1.0.0 to 1.1.0
#!/usr/bin/env node | ||
const path = require('path'); | ||
const fuckNpm = require('../index.js'); | ||
fuckNpm(); | ||
const executablePathSuffix = path.join('fuck-npm', 'bin', 'fuck-npm.js'); | ||
const executableArgvIndex = process.argv.findIndex((arg) => arg.endsWith(executablePathSuffix)); | ||
fuckNpm({ | ||
cwd: process.cwd(), | ||
removePackageLockJson: process.argv.length > executableArgvIndex + 1 | ||
}); |
16
index.js
@@ -6,3 +6,3 @@ const chalk = require('chalk'); | ||
const removeDirectory = (filepath) => { | ||
const remove = (filepath) => { | ||
console.log(chalk.yellow(`Deleting: ${filepath}`)); | ||
@@ -13,3 +13,3 @@ del.sync(filepath); | ||
const executeCommand = (command) => { | ||
const execute = (command) => { | ||
console.log(chalk.yellow(`Executing: ${command}`)); | ||
@@ -20,6 +20,10 @@ execSync(command, { stdio: [ 0, 1, 2 ] }); | ||
module.exports = () => { | ||
const nodeModulesPath = path.join(process.cwd(), 'node_modules'); | ||
removeDirectory(nodeModulesPath); | ||
executeCommand('npm install'); | ||
module.exports = ({ cwd, removePackageLockJson }) => { | ||
const nodeModulesPath = path.join(cwd, 'node_modules'); | ||
const packageLockJsonPath = path.join(cwd, 'package-lock.json'); | ||
remove(nodeModulesPath); | ||
if (removePackageLockJson) { | ||
remove(packageLockJsonPath); | ||
} | ||
execute('npm install'); | ||
}; |
{ | ||
"name": "fuck-npm", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Removes `node_modules` & runs `npm install`", | ||
@@ -37,5 +37,5 @@ "author": { | ||
"dependencies": { | ||
"chalk": "^2.4.0", | ||
"chalk": "^2.4.1", | ||
"del": "^3.0.0" | ||
} | ||
} |
@@ -7,3 +7,5 @@ # fuck-npm | ||
> The source file name(s) are larger than is supported by the file system. > Try moving to a location which has a shorter path name, or try renaming > to shorter name(s) before attempting this operation | ||
> The source file name(s) are larger than is supported by the file system. | ||
> Try moving to a location which has a shorter path name, or try renaming | ||
> to shorter name(s) before attempting this operation. | ||
@@ -16,9 +18,16 @@ ## Installation | ||
## Usage | ||
Change your current working directory to your repository directory, eg. | ||
1. Change your current working directory to your repository directory, e.g. | ||
``` | ||
cd ~/projects/my-project | ||
``` | ||
Run `fuck-npm` | ||
2. Run `fuck-npm` | ||
``` | ||
fuck-npm | ||
``` | ||
3. Relax | ||
### Frenzy mode | ||
When you're really desperate you may also want to get rid of `package-lock.json`. To do that, simply pass **any** parameter to the tool, e.g. | ||
``` | ||
fuck-npm asohdiq3iuoye | ||
``` |
3882
32
32
Updatedchalk@^2.4.1