Print file stats when things error.

This commit is contained in:
Bret Comnes 2021-01-03 15:47:32 -07:00
parent e3a5a21e0f
commit 06656fc11f
No known key found for this signature in database
GPG Key ID: 3705F4634DC3A1AC
2 changed files with 16 additions and 4 deletions

View File

@ -6,10 +6,12 @@ const ms = require('ms')
const assert = require('webassert').default const assert = require('webassert').default
const fsp = require('fs').promises const fsp = require('fs').promises
let cleanup
async function doDeploy () { async function doDeploy () {
const token = core.getInput('api_token') const token = core.getInput('api_token')
const distDir = path.join(process.cwd(), core.getInput('dist_dir')) const distDir = path.join(process.cwd(), core.getInput('dist_dir'))
const cleanup = JSON.parse(core.getInput('cleanup')) cleanup = JSON.parse(core.getInput('cleanup'))
assert(typeof cleanup === 'boolean', 'Cleanup input must be a boolean "true" or "false"') assert(typeof cleanup === 'boolean', 'Cleanup input must be a boolean "true" or "false"')
const stat = await fsp.stat(distDir) const stat = await fsp.stat(distDir)
@ -30,5 +32,15 @@ async function doDeploy () {
doDeploy().catch(err => { doDeploy().catch(err => {
console.error(err) console.error(err)
if (err.stats) {
console.log('Files to upload: ')
console.dir(err.stats.filesToUpload, { colors: true, depth: 999 })
if (cleanup) {
console.log('Files to delete: ')
console.dir(err.stats.filesToDelete, { colors: true, depth: 999 })
}
}
core.setFailed(err.message) core.setFailed(err.message)
}) })

View File

@ -8,9 +8,9 @@
}, },
"dependencies": { "dependencies": {
"@actions/core": "1.2.6", "@actions/core": "1.2.6",
"async-neocities": "1.1.6", "async-neocities": "1.1.7",
"ms": "^2.1.2", "ms": "2.1.2",
"webassert": "^3.0.2" "webassert": "3.0.2"
}, },
"devDependencies": { "devDependencies": {
"auto-changelog": "^2.0.0", "auto-changelog": "^2.0.0",