Comparing version 5.0.0 to 6.0.0
#!/usr/bin/env node | ||
const ghpages = require('../lib/index.js'); | ||
const program = require('commander'); | ||
const {Command} = require('commander'); | ||
const path = require('path'); | ||
@@ -9,5 +9,5 @@ const pkg = require('../package.json'); | ||
function publish(config) { | ||
function publish(dist, config) { | ||
return new Promise((resolve, reject) => { | ||
const basePath = path.resolve(process.cwd(), program.dist); | ||
const basePath = path.resolve(process.cwd(), dist); | ||
ghpages.publish(basePath, config, (err) => { | ||
@@ -24,5 +24,8 @@ if (err) { | ||
return Promise.resolve().then(() => { | ||
program | ||
const program = new Command() | ||
.version(pkg.version) | ||
.option('-d, --dist <dist>', 'Base directory for all source files') | ||
.requiredOption( | ||
'-d, --dist <dist>', | ||
'Base directory for all source files' | ||
) | ||
.option( | ||
@@ -81,8 +84,10 @@ '-s, --src <src>', | ||
const options = program.opts(); | ||
let user; | ||
if (program.user) { | ||
const parts = addr.parseOneAddress(program.user); | ||
if (options.user) { | ||
const parts = addr.parseOneAddress(options.user); | ||
if (!parts) { | ||
throw new Error( | ||
`Could not parse name and email from user option "${program.user}" ` + | ||
`Could not parse name and email from user option "${options.user}" ` + | ||
'(format should be "Your Name <email@example.com>")' | ||
@@ -94,4 +99,4 @@ ); | ||
let beforeAdd; | ||
if (program.beforeAdd) { | ||
const m = require(require.resolve(program.beforeAdd, { | ||
if (options.beforeAdd) { | ||
const m = require(require.resolve(options.beforeAdd, { | ||
paths: [process.cwd()], | ||
@@ -107,3 +112,3 @@ })); | ||
`Could not find function to execute before adding files in ` + | ||
`"${program.beforeAdd}".\n ` | ||
`"${options.beforeAdd}".\n ` | ||
); | ||
@@ -114,17 +119,17 @@ } | ||
const config = { | ||
repo: program.repo, | ||
silent: !!program.silent, | ||
branch: program.branch, | ||
src: program.src, | ||
dest: program.dest, | ||
message: program.message, | ||
tag: program.tag, | ||
git: program.git, | ||
depth: program.depth, | ||
dotfiles: !!program.dotfiles, | ||
add: !!program.add, | ||
remove: program.remove, | ||
remote: program.remote, | ||
push: !!program.push, | ||
history: !!program.history, | ||
repo: options.repo, | ||
silent: !!options.silent, | ||
branch: options.branch, | ||
src: options.src, | ||
dest: options.dest, | ||
message: options.message, | ||
tag: options.tag, | ||
git: options.git, | ||
depth: options.depth, | ||
dotfiles: !!options.dotfiles, | ||
add: !!options.add, | ||
remove: options.remove, | ||
remote: options.remote, | ||
push: !!options.push, | ||
history: !!options.history, | ||
user: user, | ||
@@ -134,3 +139,3 @@ beforeAdd: beforeAdd, | ||
return publish(config); | ||
return publish(options.dist, config); | ||
}); | ||
@@ -145,3 +150,3 @@ } | ||
.catch((err) => { | ||
process.stderr.write(`${err.message}\n`, () => process.exit(1)); | ||
process.stderr.write(`${err.stack}\n`, () => process.exit(1)); | ||
}); | ||
@@ -148,0 +153,0 @@ } |
{ | ||
"name": "gh-pages", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"description": "Publish to a gh-pages branch on GitHub (or any other branch on any other remote)", | ||
@@ -38,7 +38,7 @@ "keywords": [ | ||
"async": "^3.2.4", | ||
"commander": "^2.18.0", | ||
"commander": "^11.0.0", | ||
"email-addresses": "^5.0.0", | ||
"filenamify": "^4.3.0", | ||
"find-cache-dir": "^3.3.1", | ||
"fs-extra": "^8.1.0", | ||
"fs-extra": "^11.1.1", | ||
"globby": "^6.1.0" | ||
@@ -45,0 +45,0 @@ }, |
@@ -12,3 +12,3 @@ | ||
This module requires Git >= 1.9 and Node >= 12. | ||
This module requires Git >= 1.9 and Node > 14. | ||
@@ -68,3 +68,3 @@ ## Basic Usage | ||
The default options work for simple cases. The options described below let you push to alternate branches, customize your commit messages, and more. | ||
The default options work for simple cases. The options described below let you push to alternate branches, customize your commit messages and more. | ||
@@ -76,3 +76,3 @@ | ||
The [minimatch](https://github.com/isaacs/minimatch) pattern or array of patterns used to select which files should be published. | ||
The [minimatch](https://github.com/isaacs/minimatch) pattern or array of patterns is used to select which files should be published. | ||
@@ -79,0 +79,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
38588
811
+ Addedcommander@11.1.0(transitive)
+ Addedfs-extra@11.2.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addeduniversalify@2.0.1(transitive)
- Removedcommander@2.20.3(transitive)
- Removedfs-extra@8.1.0(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removeduniversalify@0.1.2(transitive)
Updatedcommander@^11.0.0
Updatedfs-extra@^11.1.1