-
Notifications
You must be signed in to change notification settings - Fork 114
/
purge_cache.js
51 lines (47 loc) · 1.05 KB
/
purge_cache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict'
const cli = require('heroku-cli-util')
const co = require('co')
const {Dyno} = require('heroku-run')
function * run (context) {
const repo = require('../lib/repo')
const app = context.app
let dyno = new Dyno({
heroku: cli.heroku,
app,
attach: true,
command: `set -e
mkdir -p tmp/repo_tmp/unpack
cd tmp/repo_tmp
curl -o repo-cache.tgz '${yield repo.getCacheURL(app)}'
cd unpack
tar -zxf ../repo-cache.tgz
METADATA="vendor/heroku"
if [ -d "$METADATA" ]; then
TMPDIR=\`mktemp -d\`
cp -rf $METADATA $TMPDIR
fi
cd ..
rm -rf unpack
mkdir unpack
cd unpack
TMPDATA="$TMPDIR/heroku"
VENDOR="vendor"
if [ -d "$TMPDATA" ]; then
mkdir $VENDOR
cp -rf $TMPDATA $VENDOR
rm -rf $TMPDIR
fi
tar -zcf ../cache-repack.tgz .
curl -o /dev/null --upload-file ../cache-repack.tgz '${yield repo.putCacheURL(app)}'
exit`
})
yield dyno.start()
}
module.exports = {
topic: 'repo',
command: 'purge_cache',
description: 'deletes the contents the build cache in the repository',
needsAuth: true,
needsApp: true,
run: cli.command(co.wrap(run))
}