mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-15 03:04:37 +03:00
72 lines
2.0 KiB
JavaScript
Executable File
72 lines
2.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
var cp = require('./utils/child-process-wrapper.js');
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
var os = require('os');
|
|
|
|
var isWindows = process.platform === 'win32';
|
|
var removeCommand = isWindows ? 'rmdir /S /Q ' : 'rm -rf ';
|
|
var productName = require('../package.json').productName;
|
|
|
|
process.chdir(path.dirname(__dirname));
|
|
var home = process.env[isWindows ? 'USERPROFILE' : 'HOME'];
|
|
var tmpdir = os.tmpdir();
|
|
|
|
// Windows: Use START as a way to ignore error if Atom.exe isnt running
|
|
var killatom = isWindows ? 'START taskkill /F /IM ' + productName + '.exe' : 'pkill -9 ' + productName + ' || true';
|
|
|
|
var commands = [
|
|
killatom,
|
|
[__dirname, '..', 'node_modules'],
|
|
[__dirname, '..', 'build', 'node_modules'],
|
|
[__dirname, '..', 'apm', 'node_modules'],
|
|
[__dirname, '..', 'atom-shell'],
|
|
[__dirname, '..', 'electron'],
|
|
[__dirname, '..', 'out'],
|
|
[home, '.atom', '.node-gyp'],
|
|
[home, '.atom', 'storage'],
|
|
[home, '.atom', '.apm'],
|
|
[home, '.atom', '.npm'],
|
|
[home, '.atom', 'compile-cache'],
|
|
[home, '.atom', 'atom-shell'],
|
|
[home, '.atom', 'electron'],
|
|
[tmpdir, 'atom-build'],
|
|
[tmpdir, 'atom-cached-atom-shells'],
|
|
];
|
|
var run = function() {
|
|
var next = commands.shift();
|
|
if (!next)
|
|
process.exit(0);
|
|
|
|
if (Array.isArray(next)) {
|
|
var pathToRemove = path.resolve.apply(path.resolve, next);
|
|
if (fs.existsSync(pathToRemove)) {
|
|
if (isWindows) {
|
|
removeFolderRecursive(pathToRemove);
|
|
} else {
|
|
next = removeCommand + pathToRemove;
|
|
cp.safeExec(next, run);
|
|
}
|
|
}
|
|
else {
|
|
return run();
|
|
}
|
|
}
|
|
else
|
|
cp.safeExec(next, run);
|
|
};
|
|
run();
|
|
|
|
// Windows has a 260-char path limit for rmdir etc. Just recursively delete in Node.
|
|
var removeFolderRecursive = function(folderPath) {
|
|
fs.readdirSync(folderPath).forEach(function(entry, index) {
|
|
var entryPath = path.join(folderPath, entry);
|
|
if (fs.lstatSync(entryPath).isDirectory()) {
|
|
removeFolderRecursive(entryPath);
|
|
} else {
|
|
fs.unlinkSync(entryPath);
|
|
}
|
|
});
|
|
fs.rmdirSync(folderPath);
|
|
};
|