-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update to es6 and async/await. * Update travis.yml to stop building on node < 8
- Loading branch information
1 parent
422e112
commit 0cbe4c9
Showing
20 changed files
with
2,760 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,49 @@ | ||
#! /usr/bin/env node | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var program = require('commander'); | ||
const path = require('path'); | ||
const program = require('commander'); | ||
|
||
var validator = require('../lib/validator'); | ||
var generate = require('../lib/generate'); | ||
var clean = require('../lib/clean'); | ||
var commandPkg = require('../package'); | ||
const validator = require('../lib/validator'); | ||
const generate = require('../lib/generate'); | ||
const clean = require('../lib/clean'); | ||
const commandPkg = require('../package'); | ||
|
||
var cwd = process.cwd(); | ||
var isValid = validator(cwd); | ||
const cwd = process.cwd(); | ||
const isValid = validator(cwd); | ||
|
||
if (!isValid) { | ||
// eslint-disable-next-line no-console | ||
console.error('Please run speculate from within a valid Node.js project'); | ||
process.exit(1); | ||
} | ||
|
||
var projectPkg = require(path.resolve(cwd, './package.json')); | ||
const projectPkg = require(path.resolve(cwd, './package.json')); | ||
|
||
program | ||
.version(commandPkg.version) | ||
.option('-r --release <release>', 'Specify release number of package') | ||
.option('-n --name <name>', 'Specify custom name for package') | ||
.parse(process.argv); | ||
|
||
// Commander has a magic property called name when not overriden by a parameter | ||
var name = program.name instanceof Function ? undefined : program.name; | ||
|
||
clean(cwd, projectPkg); | ||
generate(cwd, projectPkg, program.release, name, function (err, generated) { | ||
if (err) { | ||
// Commander has a magic property called name when not overridden by a parameter | ||
const name = program.name instanceof Function ? undefined : program.name; | ||
|
||
async function runTasks() { | ||
clean(cwd, projectPkg); | ||
|
||
try { | ||
const files = await generate(cwd, projectPkg, program.release, name); | ||
files.forEach((file) => { | ||
// eslint-disable-next-line no-console | ||
console.log('Created ./%s', file); | ||
}); | ||
process.exit(0); | ||
} catch (err) { | ||
// eslint-disable-next-line no-console | ||
console.error('Error:', err.message); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
generated.forEach(function (file) { | ||
console.log('Created ./%s', file); | ||
}); | ||
process.exit(0); | ||
}); | ||
runTasks(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
var tar = require('tar-fs'); | ||
var fs = require('fs'); | ||
var zlib = require('zlib'); | ||
var path = require('path'); | ||
'use strict'; | ||
|
||
var IGNORE_REGEX = /SOURCES|SPECS|RPMS|SRPMS|\.git/; | ||
const tar = require('tar-fs'); | ||
const fs = require('fs'); | ||
const zlib = require('zlib'); | ||
const path = require('path'); | ||
|
||
module.exports.compress = function (source, target, cb) { | ||
var gzip = zlib.createGzip(); | ||
var ws = fs.createWriteStream(target); | ||
var rs = tar.pack(source, { | ||
const IGNORE_REGEX = /SOURCES|SPECS|RPMS|SRPMS|\.git/; | ||
|
||
module.exports.compress = async function (source, target) { | ||
const gzip = zlib.createGzip(); | ||
const ws = fs.createWriteStream(target); | ||
const rs = tar.pack(source, { | ||
ignore: function (name) { | ||
return IGNORE_REGEX.test(path.relative(source, name)); | ||
} | ||
}); | ||
|
||
rs.on('error', cb); | ||
ws.on('error', cb); | ||
ws.on('close', cb); | ||
return new Promise((resolve, reject) => { | ||
rs.on('error', reject); | ||
ws.on('error', reject); | ||
ws.on('close', resolve); | ||
|
||
rs.pipe(gzip).pipe(ws); | ||
rs.pipe(gzip).pipe(ws); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
var hogan = require('hogan.js'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var getServiceProperties = require('./serviceProperties'); | ||
'use strict'; | ||
|
||
var templateFile = fs.readFileSync(path.resolve(__dirname, '../templates/service.mustache'), 'utf-8'); | ||
var template = hogan.compile(templateFile); | ||
const hogan = require('hogan.js'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const getServiceProperties = require('./serviceProperties'); | ||
|
||
const templateFile = fs.readFileSync(path.resolve(__dirname, '../templates/service.mustache'), 'utf-8'); | ||
const template = hogan.compile(templateFile); | ||
|
||
module.exports = function (pkg) { | ||
var serviceProperties = getServiceProperties(pkg); | ||
const serviceProperties = getServiceProperties(pkg); | ||
|
||
return template.render(serviceProperties); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.