Skip to content

Commit

Permalink
imporves compile output
Browse files Browse the repository at this point in the history
  • Loading branch information
sintaxi committed Sep 9, 2022
1 parent fa155fe commit 678244f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bin/harp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ if (argv["_"].length === 2){
console.log(" ", "Generating Site & Bundling Assets...".blue)
console.log()

harp.compile(projectPath, buildPath, function(errors, output){
harp.compile(projectPath, buildPath, { output: true }, function(errors, output){
if(errors) {
console.log(JSON.stringify(errors, null, 2))
process.exit(1)
Expand Down
15 changes: 12 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ exports.middleware = middleware;
*
*/

exports.compile = function(projectPath, outputPath, callback){
exports.compile = function(projectPath, outputPath, options, callback){
if (!callback){
callback = options
options = { output: false }
}

const compileStart = process.hrtime()

var stats = {
Expand Down Expand Up @@ -225,7 +230,9 @@ exports.compile = function(projectPath, outputPath, callback){
var sizeHuman = toHuman(sizeInBytes)
var sizePadded = sizeHuman.padStart(8, " ")
var filePath = `/${ terraform.helpers.outputPath(file) }`
console.log(sizePadded.green, filePath)
if (options.output){
console.log(sizePadded.green, filePath)
}
fs.writeFile(dest, body, done)
})
})
Expand All @@ -248,7 +255,9 @@ exports.compile = function(projectPath, outputPath, callback){
var sizeHuman = toHuman(sizeInBytes)
var sizePadded = sizeHuman.padStart(8, " ")
var filePath = `/${ file }`
console.log(sizePadded.grey, filePath)
if (options.output){
console.log(sizePadded.grey, filePath)
}
fs.copy(path.resolve(setup.publicPath, file), localPath, done)
})
})
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "harp",
"version": "0.44.0",
"version": "0.45.0",
"description": "Static Web Server/Generator/Bundler",
"author": "Brock Whitten <[email protected]>",
"contributors": [
Expand Down
4 changes: 2 additions & 2 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ describe("basic", function(){

before(function(done){
harp.compile(projectPath, outputPath, function(errors, output){
config = output
config = output.config
server = harp.server(projectPath).listen(8100, done)
})
})

it("should have node version in config", function(done){
it("should have harp version in config", function(done){
config.should.have.property("harp_version")
done()
})
Expand Down
8 changes: 4 additions & 4 deletions test/plain.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe("plain", function(){

before(function(done){
harp.compile(projectPath, outputPath, function(errors, output){
config = output
config = output.config
server = harp.server(projectPath).listen(8102, done)
})
})

it("should have node version in config", function(done){
it("should have harp version in config", function(done){
config.should.have.property("harp_version")
done()
})
Expand Down Expand Up @@ -75,12 +75,12 @@ describe("plain", function(){

before(function(done){
harp.compile(projectPath, outputPath, function(errors, output){
config = output
config = output.config
server = harp.server(projectPath).listen(8103, done)
})
})

it("should have node version in config", function(done){
it("should have harp version in config", function(done){
config.should.have.property("harp_version")
done()
})
Expand Down

0 comments on commit 678244f

Please sign in to comment.