Skip to content

Commit

Permalink
fix: references to package.json
Browse files Browse the repository at this point in the history
importing package.json directly from the require / import system causes
it to be bundled with the transpiled code in ./lib which then causes
problems with release.

Closes #249
  • Loading branch information
moltar committed Mar 6, 2020
1 parent 6547fb6 commit 0875792
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"eslint-plugin-jest": "23.8.1",
"eslint-plugin-prettier": "3.1.2",
"jest": "25.1.0",
"package-json-type": "1.0.3",
"prettier": "1.19.1",
"rimraf": "3.0.2",
"semantic-release": "17.0.4",
Expand Down
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { name, version } from '../package.json'
import pkg from './package'

export const USER_AGENT = `${name}/${version}`
export const USER_AGENT = `${pkg.name}/${pkg.version}`

export const JSON_CONTENT_TYPE = 'application/json'
9 changes: 9 additions & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { readFileSync } from 'fs'
import { join } from 'path'
import { IPackageJson } from 'package-json-type'

const packageJson: IPackageJson = JSON.parse(
readFileSync(join(__dirname, '../package.json'), { encoding: 'utf8' }),
)

export default packageJson
11 changes: 11 additions & 0 deletions test/package.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pkg from '../src/package'

describe('package', () => {
it('should have package name', () => {
expect(pkg.name).toBe('amazon-advertising-api-sdk')
})

it('should have package version', () => {
expect(pkg.version).toMatch(/^\d+\.\d+\.\d+$/)
})
})

0 comments on commit 0875792

Please sign in to comment.