From 43dc04f030e0f2ec819474a65982229b6a747e8b Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Tue, 18 Feb 2020 10:20:22 -0700 Subject: [PATCH] refactor: Add better assertions on the dist_dir input --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c420c8e..54752ad 100644 --- a/index.js +++ b/index.js @@ -4,12 +4,16 @@ const Neocities = require('async-neocities') const path = require('path') const ms = require('ms') const assert = require('nanoassert') +const fsp = require('fs').promises async function doDeploy () { const token = core.getInput('api_token') 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"') + const stat = await fsp.stat() + assert(stat.isDirectory(), 'dist_dir must be a directory that exists') const client = new Neocities(token)