Skip to content

Commit da53806

Browse files
committed
build: Resolve {h} in --out
1 parent d40c008 commit da53806

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

lib/build.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,14 @@ function build(opts) {
7979
if (opts.banner) {
8080
output = banner[ext].replace(/\{0\}/g, opts.banner) + output
8181
}
82-
var outFile = out.replace(/.*\//, "")
83-
, bytes = write(outDir, outFile + "?{h}", output)
84-
console.log("# Build %s %s", outFile, bytes)
82+
var outFile = write(outDir, out.replace(/.*\//, ""), output)
83+
console.log("# Build %s %s", path.basename(outFile), output.length)
8584

8685
if (opts.worker) {
8786
updateWorker(opts.worker, opts, {})
8887
}
8988
child.execSync("git add -u")
90-
if (opts._bytes) console.log("# Total %s bytes", opts._bytes + bytes)
89+
if (opts._bytes) console.log("# Total %s bytes", opts._bytes + output.length)
9190
}
9291
}
9392

@@ -136,7 +135,7 @@ function write(dir, name, content, el) {
136135
}
137136
}
138137
cli.writeFile(outFile, content)
139-
return content.length
138+
return outFile
140139
}
141140

142141
function html(opts, next) {
@@ -200,9 +199,9 @@ function html(opts, next) {
200199

201200
opts._bytes = 0
202201
pendingWrites.forEach(function(w) {
203-
var bytes = write(w.dir, w.name, w.content, w.el)
204-
console.log("# Write %s %s", w.name.split("?")[0], bytes)
205-
opts._bytes += bytes
202+
var outFile = write(w.dir, w.name, w.content, w.el)
203+
console.log("# Write %s %s", path.basename(outFile), w.content.length)
204+
opts._bytes += w.content.length
206205
})
207206

208207
$$("[inline],[min]").forEach(function(el) {

test/build.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ describe("build", function() {
7878
test("ui build with --min", function(assert, mock) {
7979
mock.swap(console, "error", mock.fn())
8080
mock.swap(console, "log", mock.fn())
81-
build({ _: files, min: temp + "min.ui" })
82-
assert.matchSnapshot(temp + "min.ui", 0, "test/data/snap/ui-build/min.ui")
81+
build({ _: files, min: temp + "min-{h}.ui" })
82+
var out = cli.ls(temp + "*.ui", { dir: false })
83+
assert.equal(out.length, 1)
84+
assert.ok(out[0].indexOf("{h}") < 0, "hash should be resolved")
85+
assert.matchSnapshot(out[0], 0, "test/data/snap/ui-build/min.ui")
8386
cli.rmrf(temp)
8487
assert.end()
8588
})

0 commit comments

Comments
 (0)