@@ -30,10 +30,12 @@ internals.prepareFixture = async ({ travisYml, packageJson, git = true } = {}) =
30
30
Fs . copyFileSync ( Path . join ( __dirname , 'fixtures' , travisYml ) , Path . join ( tmpObj . name , '.travis.yml' ) ) ;
31
31
}
32
32
33
- Fs . writeFileSync ( Path . join ( tmpObj . name , 'package.json' ) , JSON . stringify ( packageJson || {
34
- name : 'test-module' ,
35
- version : '0.0.0-development'
36
- } ) ) ;
33
+ if ( packageJson !== false ) {
34
+ Fs . writeFileSync ( Path . join ( tmpObj . name , 'package.json' ) , JSON . stringify ( packageJson || {
35
+ name : 'test-module' ,
36
+ version : '0.0.0-development'
37
+ } ) ) ;
38
+ }
37
39
38
40
if ( git ) {
39
41
const simpleGit = SimpleGit ( tmpObj . name ) ;
@@ -125,7 +127,7 @@ describe('node-support', () => {
125
127
it ( 'returns the single node version' , async ( ) => {
126
128
127
129
const path = await internals . prepareFixture ( {
128
- travisYml : '_single -version.yml'
130
+ travisYml : 'testing-single -version.yml'
129
131
} ) ;
130
132
131
133
const result = await NodeSupport . detect ( { path } ) ;
@@ -145,7 +147,7 @@ describe('node-support', () => {
145
147
it ( 'returns default node version' , async ( ) => {
146
148
147
149
const path = await internals . prepareFixture ( {
148
- travisYml : '_minimal .yml'
150
+ travisYml : 'testing-minimal .yml'
149
151
} ) ;
150
152
151
153
const result = await NodeSupport . detect ( { path } ) ;
@@ -165,7 +167,7 @@ describe('node-support', () => {
165
167
it ( 'returns empty array when no node detected' , async ( ) => {
166
168
167
169
const path = await internals . prepareFixture ( {
168
- travisYml : '_no -node.yml'
170
+ travisYml : 'testing-no -node.yml'
169
171
} ) ;
170
172
171
173
const result = await NodeSupport . detect ( { path } ) ;
@@ -325,7 +327,7 @@ describe('node-support', () => {
325
327
it ( 'handles missing env.matrix' , async ( ) => {
326
328
327
329
const path = await internals . prepareFixture ( {
328
- travisYml : '_no -env-matrix.yml'
330
+ travisYml : 'testing-no -env-matrix.yml'
329
331
} ) ;
330
332
331
333
const result = await NodeSupport . detect ( { path } ) ;
@@ -349,6 +351,17 @@ describe('node-support', () => {
349
351
await expect ( NodeSupport . detect ( { path } ) )
350
352
. to . reject ( `${ path } is not a git repository` ) ;
351
353
} ) ;
354
+
355
+ it ( 'throws when path does not have a package.json' , async ( ) => {
356
+
357
+ const path = await internals . prepareFixture ( {
358
+ travisYml : 'testing-no-node.yml' ,
359
+ packageJson : false
360
+ } ) ;
361
+
362
+ await expect ( NodeSupport . detect ( { path } ) )
363
+ . to . reject ( `${ path } does not contain a package.json` ) ;
364
+ } ) ;
352
365
} ) ;
353
366
354
367
describe ( 'repository' , ( ) => {
0 commit comments