mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Now `script/clean` uses `del /F /Q /S` to cleanup the folders but `del /S` deletes specified files from all subdirectories, so if we pass a folder as a parameter it will only delete the files within the folder and all subfolders recursively but not the actual folders. And this can cause problems, see Issue #2487 A better way is to use `rmdir /S /Q` as it takes care of the folder itself and it's contents. /S - removes all directories and files in the specified directory in addition to the directory itself. (removes the directory tree) /Q - obvious this is quite mode I tested this approach on a couple machines that needed a clean before building and works OK with `rmdir`. It might give a warning in the console like `The system cannot find the file specified.` because not all of them are there but it can be ignored as the script will finish running.
38 lines
1.2 KiB
JavaScript
Executable File
38 lines
1.2 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
var cp = require('./utils/child-process-wrapper.js');
|
|
var path = require('path');
|
|
var os = require('os');
|
|
|
|
var removeCommand = process.platform === 'win32' ? 'rmdir /S /Q ' : '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();
|
|
|
|
// 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, '..', 'build', 'node_modules'],
|
|
[__dirname, '..', 'apm', 'node_modules'],
|
|
[__dirname, '..', 'atom-shell'],
|
|
[home, '.atom', '.node-gyp'],
|
|
[home, '.atom', 'storage'],
|
|
[home, '.atom', '.npm'],
|
|
[home, '.atom', 'compile-cache'],
|
|
[tmpdir, 'atom-build'],
|
|
[tmpdir, 'atom-cached-atom-shells'],
|
|
];
|
|
var run = function() {
|
|
var next = commands.shift();
|
|
if (!next)
|
|
process.exit(0);
|
|
if (Array.isArray(next))
|
|
next = removeCommand + path.resolve.apply(path.resolve, next);
|
|
cp.safeExec(next, run);
|
|
};
|
|
run();
|