Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Support downloading hugo extended #22

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bin/hugo-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ const argv: { [ param: string ]: any } = yargs
type: 'string',
default: 'bin/hugo'
} )
.option( 'extended', {
describe: 'Download Hugo extended',
type: 'boolean',
default: false
} )
.strict()
.argv;

// If the version does not have the format of a version number, it's an object path
// If the version does not have the format of a version number, assume it's an object path
if ( isNaN( parseFloat( argv.version ) ) ) {
const packageJson: any = require( path.resolve( process.cwd(), 'package.json' ) );
const packageJsonHugoVersion: string | null = objectPath.get( packageJson, argv.version, null );
Expand All @@ -35,7 +40,8 @@ if ( isNaN( parseFloat( argv.version ) ) ) {
}

// Run
console.log( `Download hugo binary (version "${ argv.version }") into "${ argv.destination }" ...` );
const versionString = `${ argv.version }${ argv.extended ? "_extended" : "" }`;
console.log( `Download hugo binary (version "${ versionString }") into "${ argv.destination }" ...` );
installHugo( argv.version, argv.destination )
.then( () => {
console.log( 'Success!' );
Expand All @@ -44,7 +50,7 @@ installHugo( argv.version, argv.destination )
.catch( ( error: any ) => {
console.error( 'Error!' );
if ( error.toString().indexOf( '404' ) !== -1 ) {
console.error( ` -> It seems like the hugo version "${ argv.version }" does not exist.` );
console.error( ` -> It seems like the hugo version "${ versionString }" does not exist.` );
}
console.log( '' );
console.dir( error );
Expand Down