Skip to content

Commit

Permalink
better version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Dougley committed Nov 4, 2021
1 parent 7feeecc commit ce8a6fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ COPY tsconfig.json ./
COPY package*.json ./
COPY src ./src

ENV GIT_COMMIT $(git rev-parse HEAD)

RUN npm install
RUN npm prune --production

Expand Down
8 changes: 5 additions & 3 deletions src/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import dirImport from './utils/dir-import'
info('Starting up...', 'Preflight');

(async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const revision = (await promisify(exec)('git rev-parse HEAD').catch(() => { return { stdout: require('../package.json').version } })).stdout.toString().trim()
info(`Initialzing Sentry, using revision ${revision as string}`, 'Preflight')
const revision = process.env.GIT_COMMIT ??
(await promisify(exec)('git rev-parse HEAD').catch(() => ({ stdout: undefined }))).stdout?.toString().trim() ??
process.env.npm_package_version ??
'unknown'
info(`Initialzing Sentry, using revision ${revision}`, 'Preflight')
Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: function (integrations) {
Expand Down

0 comments on commit ce8a6fa

Please sign in to comment.