Socket
Socket
Sign inDemoInstall

trash-cleaner

Package Overview
Dependencies
82
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

4

lib/cli.js

@@ -26,2 +26,4 @@ const { FileSystemConfigStore } = require('./store/file-system-config-store');

.addOption(
new Option('-t, --dry-run', 'perform a dry-run cleanup without deleting the emails'))
.addOption(
new Option('-d, --debug', 'output extra debugging info'))

@@ -54,3 +56,3 @@ .addOption(

let trashCleaner = await trashCleanerFactory.getInstance();
await trashCleaner.cleanTrash();
await trashCleaner.cleanTrash(!!options.dryRun);
}

@@ -57,0 +59,0 @@ catch (err) {

@@ -22,4 +22,6 @@ const ora = require('ora');

* An event that fires when cleaning has started.
*
* @param {boolean} dryRun Do a dry-run cleanup without deleting emails.
*/
onStart() {
onStart(dryRun) {
if (this._cliMode) {

@@ -30,2 +32,3 @@ this._spinner = ora('Starting cleaning...');

}
this._dryRun = dryRun;
this._trashEmails = [];

@@ -73,3 +76,3 @@ this._unreadEmailCount = 0;

onTrashDeleted() {
this._update('Trash emails deleted.');
this._update(`Trash emails${this._dryRun ? ' not' : ''} deleted.`);
}

@@ -94,2 +97,6 @@

console.log(`Total no. of trash emails: ${this._trashEmails.length}`);
if (this._dryRun) {
console.log();
console.log(`Emails not deleted in dry-run mode.`)
}
}

@@ -96,0 +103,0 @@

@@ -8,4 +8,6 @@ /**

* An event that fires when cleaning has started.
*
* @param {boolean} dryRun Do a dry-run cleanup without deleting emails.
*/
onStart() { }
onStart(dryRun) { }

@@ -12,0 +14,0 @@ /**

@@ -106,5 +106,7 @@ const diacriticLess = require('diacriticless');

* Cleans trash email from the mailbox.
*
* @param {boolean} dryRun Do a dry-run cleanup without deleting emails.
*/
async cleanTrash() {
this._reporter.onStart();
async cleanTrash(dryRun) {
this._reporter.onStart(dryRun);

@@ -114,3 +116,3 @@ try {

await this.deleteTrashEmails(emails);
await this.deleteTrashEmails(emails, dryRun);
}

@@ -126,4 +128,5 @@ finally {

* @param {Email[]} emails The trash emails to delete.
* @param {boolean} dryRun Do a dry-run cleanup without deleting emails.
*/
async deleteTrashEmails(emails) {
async deleteTrashEmails(emails, dryRun) {
if (emails.length == 0) {

@@ -134,3 +137,5 @@ return;

this._reporter.onDeletingTrash();
await this._client.deleteEmails(emails);
if (!dryRun) {
await this._client.deleteEmails(emails);
}
this._reporter.onTrashDeleted();

@@ -137,0 +142,0 @@ }

{
"name": "trash-cleaner",
"version": "1.0.1",
"version": "1.0.2",
"description": "Finds and deletes trash email in the mailbox",

@@ -5,0 +5,0 @@ "keywords": [

@@ -5,14 +5,29 @@ # Trash Cleaner

## Setup
## Prerequisites
1. Install [Node.js & npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
2. Create a [Google Cloud Platform project with the API enabled](https://developers.google.com/workspace/guides/create-project).
3. Create [Authorization credentials for a desktop application](https://developers.google.com/workspace/guides/create-credentials) and download `credentials.json` file in the config directory.
4. Run `npm install` in the project directory.
5. Rename `keywords.json.sample` file in the config directory to `keywords.json` and update its contents.
6. Run `node .`
[Node.js & npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
## Options
## Installation
### Via NPM
```bash
npm install -g trash-cleaner
```
### Via GitHub
```
git clone https://github.com/hasankhan/trash-cleaner
cd trash-cleaner
# If you want to try out the development version then 'git checkout dev'
npm install -g
```
## Configuration
1. Create a [Google Cloud Platform project with the API enabled](https://developers.google.com/workspace/guides/create-project).
2. Create [Authorization credentials for a desktop application](https://developers.google.com/workspace/guides/create-credentials) and download `credentials.json` file in the `config` directory.
3. Rename `keywords.json.sample` file in the `config` directory to `keywords.json` and update its contents.
## Get Started
To get the list of all parameters type `trash-cleaner -h`
```
Usage: trash-cleaner [options]

@@ -22,2 +37,3 @@

-V, --version output the version number
-t, --dry-run perform a dry-run cleanup without deleting the emails
-d, --debug output extra debugging info

@@ -24,0 +40,0 @@ -c, --configDirPath <path> the path to config directory (default: "config")

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