Add trash module
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
/// <reference path="../../../../lib/vscode/src/typings/electron.d.ts" />
|
||||
import { exec } from "child_process";
|
||||
import { EventEmitter } from "events";
|
||||
import * as fs from "fs";
|
||||
import { promisify } from "util";
|
||||
import { logger, field } from "@coder/logger";
|
||||
import { escapePath } from "@coder/protocol";
|
||||
import { IKey, Dialog as DialogBox } from "./dialog";
|
||||
import { clipboard } from "./clipboard";
|
||||
import { client } from "./client";
|
||||
|
||||
// Use this to get around Webpack inserting our fills.
|
||||
declare var _require: typeof require;
|
||||
|
||||
// tslint:disable-next-line no-any
|
||||
(global as any).getOpenUrls = (): string[] => {
|
||||
@ -97,9 +98,11 @@ class Clipboard {
|
||||
|
||||
class Shell {
|
||||
public async moveItemToTrash(path: string): Promise<void> {
|
||||
await promisify(exec)(
|
||||
`trash-put --trash-dir ${escapePath("~/.Trash")} ${escapePath(path)}`,
|
||||
);
|
||||
await client.evaluate((path) => {
|
||||
const trash = _require("trash") as typeof import("trash");
|
||||
|
||||
return trash(path);
|
||||
}, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,11 +79,10 @@ export const evaluate = (connection: SendableConnection, message: NewEvalMessage
|
||||
_Buffer: Buffer,
|
||||
require: typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__ : require,
|
||||
_require: typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__ : require,
|
||||
tslib_1: require("tslib"), // TODO: is there a better way to do this?
|
||||
setTimeout,
|
||||
}, {
|
||||
timeout: message.getTimeout() || 15000,
|
||||
});
|
||||
timeout: message.getTimeout() || 15000,
|
||||
});
|
||||
if (eventEmitter) {
|
||||
// Is an active evaluation and should NOT be ended
|
||||
eventEmitter.on("close", () => onDispose());
|
||||
|
@ -48,7 +48,7 @@ module.exports = merge({
|
||||
__dirname: false,
|
||||
setImmediate: false
|
||||
},
|
||||
externals: ["spdlog", "tslib"],
|
||||
externals: ["spdlog", "tslib", "trash"],
|
||||
entry: "./packages/server/src/cli.ts",
|
||||
target: "node",
|
||||
plugins: [
|
||||
|
Reference in New Issue
Block a user