Add script/clean

This commit is contained in:
Antonio Scandurra 2016-08-02 15:31:05 +02:00
parent c4e06d9411
commit e825d8d391
3 changed files with 52 additions and 0 deletions

13
script/clean Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env node
'use strict'
const cleanCaches = require('./lib/clean-caches')
const cleanDependencies = require('./lib/clean-dependencies')
const cleanOutputDirectory = require('./lib/clean-output-directory')
const killRunningAtomInstances = require('./lib/kill-running-atom-instances')
killRunningAtomInstances()
cleanDependencies()
cleanCaches()
cleanOutputDirectory()

View File

@ -0,0 +1,27 @@
'use strict'
const fs = require('fs-extra')
const os = require('os')
const path = require('path')
const CONFIG = require('../config')
module.exports = function () {
const cachePaths = [
path.join(CONFIG.repositoryRootPath, 'cache'),
path.join(CONFIG.homeDirPath, '.atom', '.node-gyp'),
path.join(CONFIG.homeDirPath, '.atom', 'storage'),
path.join(CONFIG.homeDirPath, '.atom', '.apm'),
path.join(CONFIG.homeDirPath, '.atom', '.npm'),
path.join(CONFIG.homeDirPath, '.atom', 'compile-cache'),
path.join(CONFIG.homeDirPath, '.atom', 'atom-shell'),
path.join(CONFIG.homeDirPath, '.atom', 'electron'),
path.join(os.tmpdir(), 'atom-build'),
path.join(os.tmpdir(), 'atom-cached-atom-shells')
]
for (let path of cachePaths) {
console.log(`Cleaning ${path}...`)
fs.removeSync(path)
}
}

View File

@ -0,0 +1,12 @@
const childProcess = require('child_process')
const CONFIG = require('../config.js')
module.exports = function () {
if (process.platform === 'win32') {
// Use START as a way to ignore error if Atom.exe isnt running
childProcess.execSync(`START taskkill /F /IM ${CONFIG.appMetadata.productName}.exe`)
} else {
childProcess.execSync(`pkill -9 ${CONFIG.appMetadata.productName} || true`)
}
}