MIT License

项目介绍

sindresorhus/trash 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,采用 MIT License 许可证,目前获得 2.7k 个 Star、81 次 Fork。

仓库全名
sindresorhus/trash
开源许可证
MIT License
Star 数
2.7k
Fork 数
81
未关闭 Issue
1

README 摘要

Move files and folders to the trash Works on macOS (10.12+), Linux, and Windows (8+). Note: The Linux implementation is not very good and not maintained. Help welcome. If no one steps up to help maintain it, I will eventually remove Linux support. In contrast to fs.unlink, del, and rimraf which permanently delete files, this only moves them to the trash, which is much safer and reversible. Install Usage API…

完整内容见 GitHub 原始 README 或本页 。

常见问题

trash 用什么语言开发?

主要使用 JavaScript 编写,采用 MIT License 许可证,目前有 2.7k 个 Star。

trash 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 trash 的源码?

可以直接克隆仓库:git clone https://github.com/sindresorhus/trash.git;安装与运行步骤见仓库 README。

trash 最近还在维护吗?

仓库最近一次更新为 2月25日,当前有 1 个未关闭 Issue;Star 数为 2.7k,可作为社区活跃度的参考。

简要分析

热度分
5482
价值分
1886
活跃状态
活跃

语言占比

JavaScript
TypeScript

Release

README

trash

Move files and folders to the trash

Works on macOS (10.12+), Linux, and Windows (8+).

Note: The Linux implementation is not very good and not maintained. Help welcome. If no one steps up to help maintain it, I will eventually remove Linux support.

In contrast to fs.unlink, del, and rimraf which permanently delete files, this only moves them to the trash, which is much safer and reversible.

Install

npm install trash

Usage

import trash from 'trash';

await trash(['*.png', '!rainbow.png']);

API

trash(input, options?)

Returns a Promise.

input

Type: string | string[]

Accepts paths and glob patterns.

Non-existent files and glob patterns that match nothing are silently ignored. If you need to know whether files were actually trashed, check for their existence beforehand.

options

Type: object

glob

Type: boolean
Default: true

Enable globbing when matching file paths.

CLI

To install the trash command, run:

npm install --global trash-cli

Info

On macOS, macos-trash is used.
On Linux, the XDG spec is followed.
On Windows, recycle-bin is used. On WSL (Windows Subsystem for Linux), files are moved to the Windows Recycle Bin.

FAQ

But I can do the same thing with mv

Not really. The mv command isn’t cross-platform and moving to trash is not just about moving the file to a “trash” directory. On all OSes you’ll run into file conflicts. The user won’t easily be able to restore the file. It won’t work on an external drive. The trash directory location varies between Windows versions. For Linux, there’s a whole spec you need to follow. On macOS, you’ll lose the Put back feature.

Windows service account behavior

When running as the Windows SYSTEM account or other service accounts, files are moved to that account’s recycle bin (e.g., C:\$Recycle.Bin\S-1-5-18\ for SYSTEM). These files won’t be visible in the normal user’s recycle bin and may accumulate over time. For service contexts, consider using direct file deletion instead.

评论

暂无评论