Use fingerprint to invalidate cache

This commit is contained in:
Antonio Scandurra 2016-07-20 19:33:34 +02:00 committed by Nathan Sobo
parent 1e00a9ad27
commit ea969d71ec
3 changed files with 29 additions and 0 deletions

View File

@ -18,10 +18,14 @@ dependencies:
- nvm install 4.4.7
- nvm use 4.4.7
- npm install -g npm
- script/fingerprint-clean
override:
- script/bootstrap
post:
- script/fingerprint-write
cache_directories:
- apm/node_modules
- build/node_modules

23
script/fingerprint-clean Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env node
var fingerprint = require('./utils/fingerprint')
if (fingerprint.fingerprintMatches()) {
console.log('node_modules matches current fingerprint ' + fingerprint.fingerprint() + ' - not removing')
return
}
var fsPlus
try {
fsPlus = require('fs-plus')
} catch (error) {
console.log(error.message)
return
}
try {
fsPlus.removeSync(path.resolve(__dirname, '..', 'node_modules'))
fsPlus.removeSync(path.resolve(__dirname, '..', 'apm', 'node_modules'))
} catch (error) {
console.error(error.message)
process.exit(1)
}

2
script/fingerprint-write Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./utils/fingerprint').writeFingerprint()