-
Notifications
You must be signed in to change notification settings - Fork 0
/
unfarp.js
executable file
·37 lines (31 loc) · 967 Bytes
/
unfarp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
const { existsSync, unlinkSync } = require("fs");
const rimraf = require("rimraf");
const { join } = require("path");
const { promisify } = require("util");
const ncp = require("ncp").ncp;
const asyncNcp = promisify(ncp);
const asyncRimraf = promisify(rimraf);
function writeLine(str = "") {
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(str);
}
(async () => {
const tempDir = join(process.cwd(), ".farp");
if (!existsSync(tempDir)) {
console.error(`Existing patch not detected. Exiting`);
process.exit(1);
}
await asyncNcp(tempDir, process.cwd());
writeLine("Restored original tsconfig files");
const file = "./tsconfig.json";
if (existsSync(file) && !existsSync(join(tempDir, file))) {
unlinkSync(file);
writeLine("Removed " + file);
}
await asyncRimraf(tempDir);
writeLine("Removed " + tempDir);
writeLine("Removed patch successfully\n");
process.exit();
})();