mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-01-16 22:56:28 +00:00
refactor: Add better assertions on the dist_dir input
This commit is contained in:
parent
7b4bdb680c
commit
43dc04f030
6
index.js
6
index.js
@ -4,12 +4,16 @@ const Neocities = require('async-neocities')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const ms = require('ms')
|
const ms = require('ms')
|
||||||
const assert = require('nanoassert')
|
const assert = require('nanoassert')
|
||||||
|
const fsp = require('fs').promises
|
||||||
|
|
||||||
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'))
|
const cleanup = 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()
|
||||||
|
assert(stat.isDirectory(), 'dist_dir must be a directory that exists')
|
||||||
|
|
||||||
const client = new Neocities(token)
|
const client = new Neocities(token)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user