Skip to content

Commit e825d8d

Browse files
author
Antonio Scandurra
committed
Add script/clean
1 parent c4e06d9 commit e825d8d

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

script/clean

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env node
2+
3+
'use strict'
4+
5+
const cleanCaches = require('./lib/clean-caches')
6+
const cleanDependencies = require('./lib/clean-dependencies')
7+
const cleanOutputDirectory = require('./lib/clean-output-directory')
8+
const killRunningAtomInstances = require('./lib/kill-running-atom-instances')
9+
10+
killRunningAtomInstances()
11+
cleanDependencies()
12+
cleanCaches()
13+
cleanOutputDirectory()

script/lib/clean-caches.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict'
2+
3+
const fs = require('fs-extra')
4+
const os = require('os')
5+
const path = require('path')
6+
7+
const CONFIG = require('../config')
8+
9+
module.exports = function () {
10+
const cachePaths = [
11+
path.join(CONFIG.repositoryRootPath, 'cache'),
12+
path.join(CONFIG.homeDirPath, '.atom', '.node-gyp'),
13+
path.join(CONFIG.homeDirPath, '.atom', 'storage'),
14+
path.join(CONFIG.homeDirPath, '.atom', '.apm'),
15+
path.join(CONFIG.homeDirPath, '.atom', '.npm'),
16+
path.join(CONFIG.homeDirPath, '.atom', 'compile-cache'),
17+
path.join(CONFIG.homeDirPath, '.atom', 'atom-shell'),
18+
path.join(CONFIG.homeDirPath, '.atom', 'electron'),
19+
path.join(os.tmpdir(), 'atom-build'),
20+
path.join(os.tmpdir(), 'atom-cached-atom-shells')
21+
]
22+
23+
for (let path of cachePaths) {
24+
console.log(`Cleaning ${path}...`)
25+
fs.removeSync(path)
26+
}
27+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const childProcess = require('child_process')
2+
3+
const CONFIG = require('../config.js')
4+
5+
module.exports = function () {
6+
if (process.platform === 'win32') {
7+
// Use START as a way to ignore error if Atom.exe isnt running
8+
childProcess.execSync(`START taskkill /F /IM ${CONFIG.appMetadata.productName}.exe`)
9+
} else {
10+
childProcess.execSync(`pkill -9 ${CONFIG.appMetadata.productName} || true`)
11+
}
12+
}

0 commit comments

Comments
 (0)