Skip to content

Commit

Permalink
feat: export version const for external tools (#428)
Browse files Browse the repository at this point in the history
The difference between version 4 and 5 is big, so we need to provide
some API to allow external tools to detect which version of the plugin
is used.
  • Loading branch information
piotr-oles committed May 27, 2020
1 parent 5665dac commit 37b8944
Show file tree
Hide file tree
Showing 6 changed files with 2,854 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Expand Up @@ -97,4 +97,4 @@ jobs:
path: lib

- name: Release
run: npx semantic-release@16.0.2
run: yarn semantic-release
9 changes: 8 additions & 1 deletion package.json
Expand Up @@ -38,7 +38,8 @@
"test:pack": "yarn pack --filename fork-ts-checker-webpack-plugin.tgz",
"test:e2e": "yarn test:pack && cross-env jest e2e --ci --runInBand --bail --verbose",
"precommit": "cross-env lint-staged && yarn build && yarn test:unit",
"commit": "cross-env git-cz"
"commit": "cross-env git-cz",
"semantic-release": "semantic-release"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -73,6 +74,11 @@
},
"devDependencies": {
"@commitlint/config-conventional": "^8.3.4",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/github": "^7.0.7",
"@semantic-release/npm": "^7.0.5",
"@semantic-release/release-notes-generator": "^9.0.1",
"@types/babel__code-frame": "^7.0.1",
"@types/cross-spawn": "^6.0.2",
"@types/eslint": "^6.8.0",
Expand Down Expand Up @@ -101,6 +107,7 @@
"mock-fs": "^4.11.0",
"prettier": "^2.0.4",
"rimraf": "^3.0.2",
"semantic-release": "^17.0.0",
"strip-ansi": "^6.0.0",
"tree-kill": "^1.2.2",
"ts-jest": "^25.3.1",
Expand Down
7 changes: 7 additions & 0 deletions release.config.js
Expand Up @@ -29,5 +29,12 @@ module.exports = {
'@semantic-release/release-notes-generator',
'@semantic-release/npm',
'@semantic-release/github',
[
'@semantic-release/exec',
{
prepareCmd:
"sed -i 's/{{VERSION}}/${nextRelease.version}/g' lib/ForkTsCheckerWebpackPlugin.js",
},
],
],
};
2 changes: 2 additions & 0 deletions src/ForkTsCheckerWebpackPlugin.ts
Expand Up @@ -18,6 +18,8 @@ import { tapErrorToLogMessage } from './hooks/tapErrorToLogMessage';
import { getForkTsCheckerWebpackPluginHooks } from './hooks/pluginHooks';

class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
static readonly version: string = '{{VERSION}}'; // will be replaced by the @semantic-release/exec

private readonly options: ForkTsCheckerWebpackPluginOptions;

constructor(options: ForkTsCheckerWebpackPluginOptions = {}) {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/ForkTsCheckerWebpackPlugin.spec.ts
Expand Up @@ -9,6 +9,10 @@ describe('ForkTsCheckerWebpackPlugin', () => {
}
);

it('exposes current version', () => {
expect(ForkTsCheckerWebpackPlugin.version).toEqual('{{VERSION}}'); // will be replaced by the @semantic-release/exec
});

it("doesn't throw an error for empty options", () => {
expect(() => new ForkTsCheckerWebpackPlugin()).not.toThrowError();
});
Expand Down

0 comments on commit 37b8944

Please sign in to comment.