File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1
1
export { default as scaffold } from './scaffolder' ;
2
+ export { default as test } from './tester' ;
Original file line number Diff line number Diff line change
1
+ import { promises as fs } from 'fs' ;
2
+
3
+ import sinon from 'sinon' ;
4
+ import { assert } from 'chai' ;
5
+ import any from '@travi/any' ;
6
+
7
+ import determineIfSemanticReleaseIsConfigured from './tester' ;
8
+
9
+ suite ( 'semantic-release predicate' , ( ) => {
10
+ let sandbox ;
11
+ const projectRoot = any . string ( ) ;
12
+
13
+ setup ( ( ) => {
14
+ sandbox = sinon . createSandbox ( ) ;
15
+
16
+ sandbox . stub ( fs , 'readFile' ) ;
17
+ } ) ;
18
+
19
+ teardown ( ( ) => sandbox . restore ( ) ) ;
20
+
21
+ test ( 'that `true` is returned when semantic-release is configured for the project' , async ( ) => {
22
+ fs . readFile
23
+ . withArgs ( `${ projectRoot } /package.json` , 'utf-8' )
24
+ . resolves ( JSON . stringify ( { ...any . simpleObject ( ) , version : '0.0.0-semantically-released' } ) ) ;
25
+
26
+ assert . isTrue ( await determineIfSemanticReleaseIsConfigured ( { projectRoot} ) ) ;
27
+ } ) ;
28
+
29
+ test ( 'that `false` is returned when semantic-release is not configured for the current project' , async ( ) => {
30
+ fs . readFile . withArgs ( `${ projectRoot } /package.json` , 'utf-8' ) . resolves ( JSON . stringify ( any . simpleObject ( ) ) ) ;
31
+
32
+ assert . isFalse ( await determineIfSemanticReleaseIsConfigured ( { projectRoot} ) ) ;
33
+ } ) ;
34
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { promises as fs } from 'fs' ;
2
+
3
+ export default async function ( { projectRoot} ) {
4
+ const { version} = JSON . parse ( await fs . readFile ( `${ projectRoot } /package.json` , 'utf-8' ) ) ;
5
+
6
+ return '0.0.0-semantically-released' === version ;
7
+ }
You can’t perform that action at this time.
0 commit comments