1
1
import test from 'ava' ;
2
+ import execa from 'execa' ;
3
+ import { fix } from '@commitlint/test' ;
4
+ import * as sander from '@marionebl/sander' ;
2
5
import resolveExtends from './resolve-extends' ;
3
6
4
7
const id = id => id ;
@@ -14,6 +17,33 @@ test('returns an equivalent object as passed in', t => {
14
17
t . deepEqual ( actual , expected ) ;
15
18
} ) ;
16
19
20
+ test . serial . failing ( 'falls back to global install' , async t => {
21
+ const prev = process . env . NPM_PACKAGES ;
22
+
23
+ const cwd = await fix . bootstrap ( 'fixtures/global-install' ) ;
24
+ const prefix = `${ cwd } /commitlint-npm-packages` ;
25
+
26
+ const npm = args => execa ( 'npm' , args , { cwd} ) ;
27
+
28
+ await sander . mkdir ( cwd , 'commitlint-npm-packages' ) ;
29
+ await npm ( [ 'install' , '--global' , '@commitlint/config-angular' , '--prefix' , prefix ] ) ;
30
+
31
+ process . env . NPM_PACKAGES = prefix ;
32
+
33
+ const input = { extends : [ '@commitlint/config-angular' ] } ;
34
+
35
+ t . notThrows ( ( ) => resolveExtends ( input , { cwd} ) ) ;
36
+
37
+ process . env . NPM_PACKAGES = prev ;
38
+ } ) ;
39
+
40
+ test . serial ( 'fails for missing extends' , async t => {
41
+ const cwd = await fix . bootstrap ( 'fixtures/missing-install' ) ;
42
+ const input = { extends : [ '@commitlint/foo-bar' ] } ;
43
+
44
+ t . throws ( ( ) => resolveExtends ( input , { cwd} ) , / C a n n o t f i n d m o d u l e " @ c o m m i t l i n t \/ f o o - b a r " f r o m / ) ;
45
+ } ) ;
46
+
17
47
test ( 'uses empty prefix by default' , t => {
18
48
const input = { extends : [ 'extender-name' ] } ;
19
49
0 commit comments