Target Folder (#268)

* Creating target folder

* Formatting
This commit is contained in:
James Ives 2020-04-30 08:29:24 -04:00 committed by GitHub
parent 88b3e1921d
commit 2f337e806c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -2,10 +2,10 @@
process.env['INPUT_FOLDER'] = 'build'
process.env['GITHUB_SHA'] = '123'
import {mkdirP, rmRF} from '@actions/io'
import {action} from '../src/constants'
import {deploy, generateBranch, init, switchToBaseBranch} from '../src/git'
import {execute} from '../src/execute'
import {rmRF} from '@actions/io'
import {deploy, generateBranch, init, switchToBaseBranch} from '../src/git'
const originalAction = JSON.stringify(action)
@ -17,7 +17,8 @@ jest.mock('@actions/core', () => ({
}))
jest.mock('@actions/io', () => ({
rmRF: jest.fn()
rmRF: jest.fn(),
mkdirP: jest.fn()
}))
jest.mock('../src/execute', () => ({
@ -402,6 +403,7 @@ describe('git', () => {
expect(execute).toBeCalledTimes(11)
expect(rmRF).toBeCalledTimes(1)
expect(mkdirP).toBeCalledTimes(1)
})
it('should stop early if there is nothing to commit', async () => {

View File

@ -1,5 +1,5 @@
import {info} from '@actions/core'
import {rmRF} from '@actions/io'
import {rmRF, mkdirP} from '@actions/io'
import {ActionInterface} from './constants'
import {execute} from './execute'
import {
@ -147,6 +147,11 @@ export async function deploy(action: ActionInterface): Promise<void> {
}
}
if (action.targetFolder) {
info(`Creating target folder if it doesn't already exist… 📌`)
await mkdirP(`${temporaryDeploymentDirectory}/${action.targetFolder}`)
}
/*
Pushes all of the build files into the deployment directory.
Allows the user to specify the root if '.' is provided.