Ability to delete without node_modules

This commit is contained in:
Kyle Robinson Young 2013-12-14 20:33:07 -08:00
parent 8239bb7e05
commit 0cf2cdceea

View File

@ -2,24 +2,33 @@
var cp = require('./utils/child-process-wrapper.js');
var path = require('path');
var os = require('os');
var rimraf = require('rimraf');
var rimraf = process.platform === 'win32' ? 'del /F /Q /S ' : 'rm -rf ';
var productName = require('../package.json').productName;
process.chdir(path.dirname(__dirname));
var home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
var tmpdir = os.tmpdir();
var command = process.platform === 'win32' ? 'taskkill /IM ' + productName + '.exe' : 'pkill -9 ' + productName;
cp.safeExec(command, function() {
[
[__dirname, '..', 'node_modules'],
[__dirname, '..', 'atom-shell'],
[home, '.atom', '.node-type'],
[home, '.atom', 'storage'],
[tmpdir, 'atom-build'],
[tmpdir, 'atom-cached-atom-shells'],
[tmpdir, 'atom-compile-cache'],
].forEach(function(filepath) {
rimraf(path.resolve.apply(path.resolve, filepath), function() {});
});
});
// Windows: Use START as a way to ignore error if Atom.exe isnt running
var killatom = process.platform === 'win32' ? 'START taskkill /F /IM ' + productName + '.exe' : 'pkill -9 ' + productName + ' || true';
var commands = [
killatom,
[__dirname, '..', 'node_modules'],
[__dirname, '..', 'atom-shell'],
[home, '.atom', '.node-type'],
[home, '.atom', 'storage'],
[tmpdir, 'atom-build'],
[tmpdir, 'atom-cached-atom-shells'],
[tmpdir, 'atom-compile-cache'],
];
var run = function() {
var next = commands.shift();
if (!next)
process.exit(0);
if (Array.isArray(next))
next = rimraf + path.resolve.apply(path.resolve, next);
cp.safeExec(next, run);
};
run();