mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Try incremental builds
This commit is contained in:
parent
522a1651c3
commit
e18262f422
4 changed files with 177 additions and 7 deletions
52
cache-me.js
Normal file
52
cache-me.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const Rsync = require('rsync')
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'PRODUCTION'
|
||||
|
||||
const CACHE_PATH = isProduction
|
||||
? path.join('/', 'opt', 'build', 'cache', 'nuxt_build') // Netlify cache path
|
||||
: path.resolve(__dirname, '.nuxt_build')
|
||||
|
||||
const BUILD_PATH = path.resolve(__dirname, 'dist')
|
||||
|
||||
const rsync = new Rsync()
|
||||
.shell('ssh')
|
||||
.flags('azq')
|
||||
.source(BUILD_PATH + '/')
|
||||
.destination(CACHE_PATH)
|
||||
|
||||
async function cacheFinalFiles() {
|
||||
try {
|
||||
await fs.copy(BUILD_PATH, CACHE_PATH)
|
||||
await fs.move(path.resolve(__dirname, '.nuxt'), path.join(CACHE_PATH, '.nuxt'))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function cacheAndCopy() {
|
||||
try {
|
||||
await fs.ensureDir(CACHE_PATH)
|
||||
rsync.execute(async function(error, code, cmd) {
|
||||
if (!error) {
|
||||
await fs.copy(CACHE_PATH, BUILD_PATH)
|
||||
await cacheFinalFiles()
|
||||
console.log('Please tell me you are well cached.')
|
||||
} else console.error('error')
|
||||
})
|
||||
} catch (err) {
|
||||
// handle error
|
||||
console.log('cache and copy ')
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
|
||||
async function putCacheBack() {
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
cacheAndCopy
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue