File tree Expand file tree Collapse file tree 4 files changed +44
-5
lines changed Expand file tree Collapse file tree 4 files changed +44
-5
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,8 @@ const result = {
64
64
// the current time when the result is returned
65
65
timestamp: 1577115956099 ,
66
66
67
- // git commit hash of the repository HEAD at the time of scanning
67
+ // git commit hash of the repository HEAD at the time of scanning `path` / `repository`
68
+ // git commit hash for git tag of the `version` when used with `package`
68
69
// will be left out when no git repository detected
69
70
commit: " 2de28c8c4ab8ac998d403509123736929131908c" ,
70
71
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- module . exports = ( ) => {
3
+ const Fs = require ( 'fs' ) ;
4
+ const Path = require ( 'path' ) ;
5
+ const Yaml = require ( 'js-yaml' ) ;
4
6
5
- throw new Error ( 'Not implemented' ) ;
7
+
8
+ module . exports . detect = ( { path } ) => {
9
+
10
+ const packageJson = require ( Path . join ( path , 'package.json' ) ) ;
11
+
12
+ const { name, version } = packageJson ;
13
+
14
+ const travisYaml = Yaml . safeLoad ( Fs . readFileSync ( Path . join ( path , '.travis.yml' ) ) , { schema : Yaml . FAILSAFE_SCHEMA } ) ;
15
+
16
+ return {
17
+ name,
18
+ version,
19
+ travis : {
20
+ raw : travisYaml . node_js
21
+ }
22
+ } ;
6
23
} ;
Original file line number Diff line number Diff line change 21
21
"@hapi/lab" : " ^21.0.0" ,
22
22
"allow-scripts" : " ^1.5.2" ,
23
23
"semantic-release" : " ^15.14.0"
24
+ },
25
+ "dependencies" : {
26
+ "js-yaml" : " ^3.13.1"
24
27
}
25
28
}
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ const Path = require ( 'path' ) ;
4
+
3
5
const NodeSupport = require ( '..' ) ;
4
6
5
7
@@ -8,8 +10,24 @@ const { expect } = require('@hapi/code');
8
10
9
11
describe ( 'node-support' , ( ) => {
10
12
11
- it ( 'is not implemented' , ( ) => {
13
+ describe ( 'detect()' , ( ) => {
14
+
15
+ describe ( 'path' , ( ) => {
16
+
17
+ it ( 'returns node versions from .travis.yml at the path' , async ( ) => {
18
+
19
+ const path = Path . join ( __dirname , '..' ) ;
20
+
21
+ const result = await NodeSupport . detect ( { path } ) ;
12
22
13
- expect ( NodeSupport ) . to . throw ( 'Not implemented' ) ;
23
+ expect ( result ) . to . equal ( {
24
+ name : 'node-support' ,
25
+ version : '0.0.0-development' ,
26
+ travis : {
27
+ raw : [ '10' , '12' , '13' ]
28
+ }
29
+ } ) ;
30
+ } ) ;
31
+ } ) ;
14
32
} ) ;
15
33
} ) ;
You can’t perform that action at this time.
0 commit comments