Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #20 from secure-rm/develop
Browse files Browse the repository at this point in the history
4.1.0
  • Loading branch information
SteelAlloy committed Oct 29, 2019
2 parents dae84ca + 3f120d8 commit 3fa3b57
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 121 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- ## [Unreleased] -->

## [4.1.0] - 2019-10-29

### Changed

- Events are now:
- 'debug'
- 'info'
- 'notice'
- 'warn'
- 'error'

### Fixed

- Npm auto publisher bug.

## [4.0.1] - 2019-10-27

### Added
Expand Down
19 changes: 10 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<p align="center">
<a href="https://jestjs.io"><img src="https://img.shields.io/badge/tested_with-jest-99424f.svg?style=for-the-badge&logo=jest" alt="Tested with Jest"></a>
<a href="https://www.npmjs.com"><img src="https://img.shields.io/librariesio/release/npm/secure-rm?style=for-the-badge&logo=npm" alt="Dependencies"></a>
<a href="https://nodejs.org"><img src="https://img.shields.io/node/v/secure-rm?style=for-the-badge" alt="Node version"></a>
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/language-typescript-blue?style=for-the-badge" alt="language"></a>
<a href="https://libraries.io/npm/secure-rm"><img src="https://img.shields.io/librariesio/release/npm/secure-rm?style=for-the-badge&logo=npm" alt="Dependencies"></a>
<img src="https://img.shields.io/github/contributors/secure-rm/core?style=for-the-badge" alt="Contributors">
<img src="https://img.shields.io/github/last-commit/secure-rm/core/develop?style=for-the-badge" alt="Last commit">
<img src="https://img.shields.io/npm/collaborators/secure-rm?style=for-the-badge" alt="npm collaborators">
</p>
<p align="center">
<img src="https://img.shields.io/github/contributors/oganexon/secure-rm?style=for-the-badge" alt="Contributors">
<img src="https://img.shields.io/github/last-commit/oganexon/secure-rm/develop?style=for-the-badge" alt="Last commit">
<img src="https://img.shields.io/npm/collaborators/secure-rm?style=for-the-badge" alt="npm collaborators">
<a href="https://jestjs.io"><img src="https://img.shields.io/badge/-jest-99424f?style=for-the-badge&logo=jest" alt="Tested with Jest"></a>
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/-node-gray?style=for-the-badge&logo=node.js" alt="Node version"></a>
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/-typescript-blue?style=for-the-badge&logo=typescript" alt="language"></a>
</p>

# Contributing / Developing
Expand Down Expand Up @@ -49,7 +49,7 @@ We use [SemVer](http://semver.org/) for versioning. For the versions available,

This project uses the framework [Jest](https://jestjs.io/). Jest is a delightful JavaScript Testing Framework with a focus on simplicity.

Simply run `jest` to run the tests.
Simply run `npm test` to run the tests.

There are not enough tests, you can add more.

Expand All @@ -63,7 +63,8 @@ You can install a [plugin](https://standardjs.com/awesome.html#editor-plugins) f

### Pull request

Please follow the [pull request template](./github/PULL_REQUEST_TEMPLATE/pull_request_template.md).
Please PR to the `develop` branch!
Then follow the [pull request template](.github/PULL_REQUEST_TEMPLATE/pull_request_template.md).

### Deploying / Publishing

Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,24 @@ srm('./folder/*.js')
- Respond to events,
- etc.

### Example:
### Examples:
```javascript
const options = {
standard: 'gutmann',
maxBusyTries: 5,
disableGlob: true
}

srm('./data/file*.js', options, (err) => {
srm('./data/*.js', options, (err) => {
if (err) throw err
console.log('Files successfully deleted !')
})

srm('./trash/dir/', { standard: 'preview' }, (err, fileTree) => {
if (err) throw err
console.log('Files that would be deleted:' + fileTree)
})

```

## 📜 Changelog / History
Expand All @@ -94,15 +100,15 @@ See the [changelog](/CHANGELOG.md) or [releases](https://github.com/oganexon/sec
## 🏗 Contributing

<p align="center">
<a href="https://jestjs.io"><img src="https://img.shields.io/badge/tested_with-jest-99424f.svg?style=flat-square&logo=jest" alt="Tested with Jest"></a>
<a href="https://www.npmjs.com"><img src="https://img.shields.io/librariesio/release/npm/secure-rm?style=flat-square&logo=npm" alt="Dependencies"></a>
<a href="https://nodejs.org"><img src="https://img.shields.io/node/v/secure-rm?style=flat-square" alt="Node version"></a>
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/github/languages/top/oganexon/secure-rm?style=flat-square" alt="language"></a>
<a href="https://libraries.io/npm/secure-rm"><img src="https://img.shields.io/librariesio/release/npm/secure-rm?style=flat-square&logo=npm" alt="Dependencies"></a>
<img src="https://img.shields.io/github/contributors/secure-rm/core?style=flat-square" alt="Contributors">
<img src="https://img.shields.io/github/last-commit/secure-rm/core/develop?style=flat-square" alt="Last commit">
<img src="https://img.shields.io/npm/collaborators/secure-rm?style=flat-square" alt="npm collaborators">
</p>
<p align="center">
<img src="https://img.shields.io/github/contributors/oganexon/secure-rm?style=flat-square" alt="Contributors">
<img src="https://img.shields.io/github/last-commit/oganexon/secure-rm/develop?style=flat-square" alt="Last commit">
<img src="https://img.shields.io/npm/collaborators/secure-rm?style=flat-square" alt="npm collaborators">
<a href="https://jestjs.io"><img src="https://img.shields.io/badge/-jest-99424f?style=flat-square&logo=jest" alt="Tested with Jest"></a>
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/-node-gray?style=flat-square&logo=node.js" alt="Node version"></a>
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/-typescript-blue?style=flat-square&logo=typescript" alt="language"></a>
</p>

See [contributing guidelines](/CONTRIBUTING.md)
Expand Down
106 changes: 37 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "secure-rm",
"version": "4.0.1",
"version": "4.1.0",
"description": "Completely erases files by making recovery impossible.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -66,8 +66,5 @@
"plugins": [
"@typescript-eslint/eslint-plugin"
]
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
}
}
24 changes: 11 additions & 13 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ export function eventError (err: NodeJS.ErrnoException, file: string): void {
if (err) {
switch (err.code) {
case 'EMFILE':
eventEmitter.emit('warn', file, `Too many open files, cannot ${err.syscall || 'access'}: `)
eventEmitter.emit('notice', file, `Too many open files, cannot ${err.syscall || 'access'}: `)
break
case 'ENOENT':
eventEmitter.emit('warn', file, 'This file no longer exists: ')
eventEmitter.emit('notice', file, 'This file no longer exists: ')
break
case 'EPERM':
eventEmitter.emit('error', file, `Operation not permitted on this file (${err.syscall}): `)
eventEmitter.emit('warn', file, `Operation not permitted on this file (${err.syscall}): `)
break
case 'ENOTEMPTY':
// Work as intended
break
default:
if (err.message === '64bit files are not yet supported.') {
eventEmitter.emit('error', file, '64bit files are not yet supported.')
eventEmitter.emit('warn', file, '64bit files are not yet supported.')
} else {
console.log(err)
throw err
eventEmitter.emit('error', file, err)
// throw err
}
// break
}
Expand All @@ -35,11 +35,9 @@ export const tree: { [key: string]: string[] } = {}
const debug = process.argv.includes('--debug')

if (debug) {
eventEmitter.on('start', (file) => console.log('Starting ' + file))
eventEmitter.on('done', (file) => console.log('Done ' + file))

eventEmitter.on('verbose', (file, info) => console.log(info + file))

eventEmitter.on('warn', (file, err) => console.log(err + file))
eventEmitter.on('error', (file, err) => console.log(err + file))
eventEmitter.on('debug', (file, message) => console.log('\x1b[38;2;128;0;128m Debug \x1b[39m' + message + file))
eventEmitter.on('info', (file, message) => console.log('\x1b[38;2;0;0;255m Info \x1b[39m' + message + file))
eventEmitter.on('notice', (file, message) => console.log('\x1b[38;2;0;255;255m Notice \x1b[39m' + message + file))
eventEmitter.on('warn', (file, message) => console.log('\x1b[38;2;255;255;0m Warn \x1b[39m' + message + file))
eventEmitter.on('error', (file, message) => console.log('\x1b[38;2;255;0;0m Error \x1b[39m' + message + file))
}
2 changes: 1 addition & 1 deletion src/secure-rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { standards, validIDs, Standard } from './standards' // eslint-disable-li
import { tree } from './events'

// to get the correct tree for each call
function getUUID() {
function getUUID () {
return crypto.randomBytes(60).toString('base64').replace(/\//g, '0').replace(/\+/g, 'a')
}

Expand Down
Loading

0 comments on commit 3fa3b57

Please sign in to comment.