Skip to content

Commit

Permalink
chore: upgrade deps
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Dec 7, 2023
1 parent ed8e31a commit 646a91d
Show file tree
Hide file tree
Showing 3 changed files with 2,913 additions and 1,688 deletions.
20 changes: 10 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path')
const util = require('util')
const execPromise = util.promisify(require('child_process').exec)
const ncp = util.promisify(require('ncp'))
const rimraf = util.promisify(require('rimraf'))
const { rimraf } = require('rimraf')
const fs = require('fs')
const readdir = util.promisify(fs.readdir)
const readFile = util.promisify(fs.readFile)
Expand All @@ -14,17 +14,17 @@ const GitUrlParse = require('git-url-parse')
const semver = require('semver')
const debug = require('debug')('gh-pages-multi')

exports.deploy = async function ({src, target, branch, remote, template, title, dryRun, history, betterTarget}) {
exports.deploy = async function ({ src, target, branch, remote, template, title, dryRun, history, betterTarget }) {
if (betterTarget) target = exports.betterTarget(target)

debug(`deploy ${src} to ${remote}:${branch}/${target}`)

const tmpDir = (await tmp.dir({keep: dryRun})).path
const tmpDir = (await tmp.dir({ keep: dryRun })).path

async function exec (cmd) {
debug(`Run command: ${cmd}`)
const res = await execPromise(cmd, {cwd: tmpDir})
if (res.stdout && res.stdout.length) debug(`output=`, res.stdout)
const res = await execPromise(cmd, { cwd: tmpDir })
if (res.stdout && res.stdout.length) debug('output=', res.stdout)
return res.stdout
}

Expand All @@ -39,7 +39,7 @@ exports.deploy = async function ({src, target, branch, remote, template, title,
// Create empty new branch
await exec(`git clone ${remote} ${tmpDir}`)
await exec(`git checkout --orphan ${branch}`)
await exec(`git rm -rf .`)
await exec('git rm -rf .')
}

let targetExists
Expand Down Expand Up @@ -67,7 +67,7 @@ exports.deploy = async function ({src, target, branch, remote, template, title,
const dirs = (await readdir(tmpDir)).filter(dir => dir.indexOf('.') !== 0 && dir !== 'index.html').sort()
const compiledTemplate = pug.compile(await readFile(template, 'utf8'))
const fullTemplatePath = path.resolve(tmpDir, 'index.html')
await writeFile(fullTemplatePath, compiledTemplate({dirs, title}))
await writeFile(fullTemplatePath, compiledTemplate({ dirs, title }))
debug(`written ${fullTemplatePath}`)
const noJekyllPath = path.resolve(tmpDir, '.nojekyll')
await writeFile(noJekyllPath, '')
Expand All @@ -77,9 +77,9 @@ exports.deploy = async function ({src, target, branch, remote, template, title,
if (dryRun) {
console.log('Dry run option activated, do not push anything')
} else {
await exec(`git add -A`)
const diffOut = await exec(`git diff --staged --name-only`)
if (diffOut.length === 0) return console.log(`No modification to validate`)
await exec('git add -A')
const diffOut = await exec('git diff --staged --name-only')
if (diffOut.length === 0) return console.log('No modification to validate')
await exec(`git commit -m "Pushed ${target} by gh-pages-multi"`)
if (history) await exec(`git push -u origin ${branch}`)
else await exec(`git push --force -u origin ${branch}`)
Expand Down
Loading

0 comments on commit 646a91d

Please sign in to comment.