1
mirror of https://github.com/jakejarvis/hugo-extended.git synced 2025-09-13 04:05:31 -04:00

Initial commit

This commit is contained in:
Shun Sato
2016-05-30 23:28:11 +09:00
committed by satoshun00
commit fdd354f25d
12 changed files with 209 additions and 0 deletions

13
lib/binary.js Normal file
View File

@@ -0,0 +1,13 @@
const path = require('path');
const BinWrapper = require('bin-wrapper');
const getBinalyName = require('./getBinalyName');
const HUGO_VERSION = '0.15';
const baseUrl = `https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/`;
const binalyNames = getBinalyName(HUGO_VERSION);
module.exports = new BinWrapper()
.src(`${baseUrl}${binalyNames.binaryName}${binalyNames.comp}`)
.dest(path.join(__dirname, '../vendor'))
.use(`${binalyNames.binaryName}${binalyNames.exe}`);

8
lib/cli.js Normal file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env node
const spawn = require('child_process').spawn;
const input = process.argv.slice(2);
const bin = require('./');
spawn(bin, input, {stdio: 'inherit'})
.on('exit', process.exit);

41
lib/getBinalyName.js Normal file
View File

@@ -0,0 +1,41 @@
const PLATFORMS = {
darwin: 'darwin',
freebsd: 'freebsd',
linux: 'linux',
// sunos: '', not supported
win32: 'windows'
};
const ARCHS = {
arm: 'arm',
ia32: '386',
x64: 'amd64'
};
const COMPS = {
darwin: '.zip',
freebsd: '.zip',
linux: '.tar.gz',
// sunos: '', not supported
win32: '.zip'
};
const EXES = {
darwin: '',
freebsd: '',
linux: '',
// sunos: '', not supported
win32: 'windows'
};
module.exports = version => {
const platform = PLATFORMS[process.platform];
const arch = ARCHS[process.arch];
const comp = COMPS[process.platform];
const exe = EXES[process.platform];
return {
binaryName: `hugo_${version}_${platform}_${arch}`,
comp,
exe
};
}

3
lib/index.js Normal file
View File

@@ -0,0 +1,3 @@
const bin = require('./binary');
module.exports = bin.path();

11
lib/install.js Normal file
View File

@@ -0,0 +1,11 @@
const bin = require('./binary');
const log = require('logalot');
bin.run(['version'], err => {
if (err) {
log.error(err.message);
log.error('Hugo binary installation failed');
return;
}
log.success('Hugo binary is installed successfully');
});