Skip to content

Commit

Permalink
fix: use ROARR_VERSION in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Feb 27, 2021
1 parent cd9a8de commit a6d7555
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .README/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,6 @@ Use [`roarr-cli`](https://github.com/gajus/roarr-cli) program to pretty-print th

## Developing

Every time a change is made to the logger, one must update `ROARR_VERSION` value in `./src/factories/createRoarrInitialGlobalState.js`.
Every time a change is made to the logger, one must update `ROARR_VERSION` value in [`./src/config.ts`](./src/config.ts).

Unfortunately, this process cannot be automated because the version number is not known before `semantic-version` is called.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,6 @@ Use [`roarr-cli`](https://github.com/gajus/roarr-cli) program to pretty-print th
<a name="roarr-developing"></a>
## Developing

Every time a change is made to the logger, one must update `ROARR_VERSION` value in `./src/factories/createRoarrInitialGlobalState.js`.
Every time a change is made to the logger, one must update `ROARR_VERSION` value in [`./src/config.ts`](./src/config.ts).

Unfortunately, this process cannot be automated because the version number is not known before `semantic-version` is called.
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This needs to be updated manually because there is no way
// to know the package version at the build time.
export const ROARR_VERSION = '4.1.5';
7 changes: 3 additions & 4 deletions src/factories/createRoarrInitialGlobalState.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import environmentIsNode from 'detect-node';
import compareSemver from 'semver-compare';
import {
ROARR_VERSION,
} from '../config';
import type {
RoarrGlobalState,
} from '../types';
import createNodeWriter from './createNodeWriter';

// This needs to be updated manually because there is no way
// to know the package version at the build time.
const ROARR_VERSION = '4.1.4';

export default (currentState: any): RoarrGlobalState => {
const versions = (currentState.versions || []).concat();

Expand Down
11 changes: 7 additions & 4 deletions test/roarr/createRoarrInitialGlobalState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import test from 'ava';
import {
ROARR_VERSION,
} from '../../src/config';
import createRoarrInitialGlobalState from '../../src/factories/createRoarrInitialGlobalState';

test('creates new state', (t) => {
Expand All @@ -7,7 +10,7 @@ test('creates new state', (t) => {
t.like(state, {
sequence: 0,
versions: [
'1.0.0',
ROARR_VERSION,
],
});
});
Expand All @@ -20,7 +23,7 @@ test('respects existing sequence', (t) => {
t.like(state, {
sequence: 1,
versions: [
'1.0.0',
ROARR_VERSION,
],
});
});
Expand All @@ -36,7 +39,7 @@ test('appends the latest version', (t) => {
sequence: 0,
versions: [
'0.0.1',
'1.0.0',
ROARR_VERSION,
],
});
});
Expand Down Expand Up @@ -64,7 +67,7 @@ test('does not override "write" method if current is not the latest version', (t

const state = createRoarrInitialGlobalState({
versions: [
'2.0.0',
'100.0.0',
],
write,
});
Expand Down

0 comments on commit a6d7555

Please sign in to comment.