Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Add tmp cleaning to clean task & appveyor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ransom Briggs committed May 22, 2017
1 parent 9b5939e commit daa37a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ test_script:
- ./node_modules/.bin/jest -i
- ./node_modules/.bin/flow check
- ./node_modules/.bin/standard
- yarn run clean

build: off
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"repository": "https://github.com/heroku/cli-engine",
"scripts": {
"build": "babel src -d lib --ignore '*.test.js'",
"clean": "rimraf lib",
"clean": "rimraf lib tmp",
"download": "node ./bin/download-yarn",
"prepare": "npm run clean && npm run build && npm run download",
"release": "np",
Expand Down
18 changes: 14 additions & 4 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ export function tmpDirs (cfg: any = {}) {
Yarn.extraOpts = ['--prefer-offline']

let testDir = path.join(path.dirname(__filename))
let dataDir = tmp.dirSync().name
let cacheDir = tmp.dirSync().name

let tmpDir = path.resolve(path.join(__dirname, '..', 'tmp'))
fs.mkdirsSync(tmpDir)

let template = path.join(tmpDir, 'tmp-XXXXXX')

let dataDir = tmp.dirSync({template}).name
let cacheDir = tmp.dirSync({template}).name

fs.mkdirs(path.join(dataDir, 'plugins'))

Expand All @@ -26,8 +32,12 @@ export function tmpDirs (cfg: any = {}) {
let plugins = new Plugins(output)

let clean = function () {
fs.removeSync(cacheDir)
fs.removeSync(dataDir)
try {
fs.removeSync(cacheDir)
fs.removeSync(dataDir)
} catch (err) {
console.warn('Unable to clean up tmp - ignore on appveyor')
}
}

return { clean, plugins, output, config, cacheDir, dataDir }
Expand Down

0 comments on commit daa37a3

Please sign in to comment.