Skip to content

Commit

Permalink
Added script to purge name or all files (#99)
Browse files Browse the repository at this point in the history
* Added script to purge name or all files

* readme
  • Loading branch information
egfanboy authored and mazipan committed Oct 7, 2019
1 parent e5feecf commit 2465cea
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ node index.js caxvis # will return this person's named caxvis to you
yarn purge
```

You can specify a name(or more) to purge only those file(s)
```shell
yarn purge joe-bob kitty-luvr73
```

## Do it with your own risk

We don't collect the data, but there is chance for other people to abuse your data that is submitted here. Please do it with your own risk, **we don't protect your data**.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "eslint \"**/*.js\" --ignore-pattern node_modules/",
"fixlint": "eslint \"**/*.js\" --ignore-pattern node_modules/ --fix",
"test": "echo \"not implement yet\"",
"purge": "rm -rf ./people"
"purge": "node ./purge"
},
"repository": {
"type": "git",
Expand Down
24 changes: 24 additions & 0 deletions purge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require("path");
const fs = require("fs");

const namesToRemove = process.argv.slice(2);

const peoplesPath = path.join(__dirname, "peoples");

if (!namesToRemove.length) {
fs.readdirSync(peoplesPath).forEach(file =>
fs.unlinkSync(path.join(peoplesPath, file))
);

fs.rmdirSync(peoplesPath);
} else {
namesToRemove.forEach(name => {
try {
fs.unlinkSync(path.join(peoplesPath, `${name}.js`));
} catch (e) {
console.error(`Error deleting file for name: ${name}`);
}
});

fs.rmdirSync(peoplesPath);
}

0 comments on commit 2465cea

Please sign in to comment.