Skip to content

Commit 3d456db

Browse files
WangJunschneidmaster
authored andcommitted
fix: uploaded files wrong when compiler.options.output.filename confi… (#78)
* fix: uploaded files wrong when compiler.options.output.filename configured like `js/[name].js?[hash:10]` * Fix lint error and configure Travis to run linter
1 parent 7992bf2 commit 3d456db

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
language: node_js
22
node_js:
3-
- "node"
3+
- "node"
4+
script:
5+
- yarn lint
6+
- yarn test

src/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import request from 'request-promise'
2-
import path from 'path'
32
import fs from 'fs'
43
import PromisePool from 'es6-promise-pool'
54

@@ -87,7 +86,7 @@ module.exports = class SentryPlugin {
8786
return
8887
}
8988

90-
const files = this.getFiles(compiler, compilation)
89+
const files = this.getFiles(compilation)
9190

9291
if (typeof this.releaseVersion === 'function') {
9392
this.releaseVersion = this.releaseVersion(compilation.hash)
@@ -111,7 +110,7 @@ module.exports = class SentryPlugin {
111110

112111
compiler.hooks.done.tapPromise('SentryPlugin', async (stats) => {
113112
if (this.deleteAfterCompile) {
114-
await this.deleteFiles(compiler, stats)
113+
await this.deleteFiles(stats)
115114
}
116115
})
117116
}
@@ -147,12 +146,11 @@ module.exports = class SentryPlugin {
147146
}
148147
}
149148

150-
getFiles(compiler, compilation) {
149+
getFiles(compilation) {
151150
return Object.keys(compilation.assets)
152151
.map((name) => {
153152
if (this.isIncludeOrExclude(name)) {
154-
const filePath = path.join(compiler.options.output.path, name)
155-
return { name, filePath }
153+
return { name, filePath: compilation.assets[name].existsAt }
156154
}
157155
return null
158156
})
@@ -236,11 +234,11 @@ module.exports = class SentryPlugin {
236234
}/releases`
237235
}
238236

239-
async deleteFiles(compiler, stats) {
237+
async deleteFiles(stats) {
240238
Object.keys(stats.compilation.assets)
241239
.filter(name => this.deleteRegex.test(name))
242240
.forEach((name) => {
243-
const filePath = path.join(compiler.options.output.path, name)
241+
const filePath = stats.compilation.assets[name].existsAt
244242
fs.unlinkSync(filePath)
245243
})
246244
}

0 commit comments

Comments
 (0)