@@ -2,12 +2,11 @@ import path from 'node:path';
2
2
import fs from 'node:fs' ;
3
3
import process from 'node:process' ;
4
4
import tempWrite from 'temp-write' ;
5
- import dotProp from 'dot-prop' ;
5
+ import { getProperty } from 'dot-prop' ;
6
6
import test from 'ava' ;
7
7
import createXo from './index.js' ;
8
8
9
9
const originalArgv = [ ...process . argv ] ;
10
- const { get} = dotProp ;
11
10
12
11
async function run ( pkg ) {
13
12
const filepath = tempWrite . sync ( JSON . stringify ( pkg ) , 'package.json' ) ;
@@ -22,8 +21,8 @@ async function run(pkg) {
22
21
23
22
test ( 'empty package.json' , async t => {
24
23
const pkg = await run ( { } ) ;
25
- t . is ( get ( pkg , 'scripts.test' ) , 'xo' ) ;
26
- t . is ( get ( pkg , 'xo' ) , undefined ) ;
24
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo' ) ;
25
+ t . is ( getProperty ( pkg , 'xo' ) , undefined ) ;
27
26
} ) ;
28
27
29
28
test ( 'has scripts' , async t => {
@@ -33,8 +32,8 @@ test('has scripts', async t => {
33
32
} ,
34
33
} ) ;
35
34
36
- t . is ( get ( pkg , 'scripts.test' ) , 'xo' ) ;
37
- t . is ( get ( pkg , 'xo' ) , undefined ) ;
35
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo' ) ;
36
+ t . is ( getProperty ( pkg , 'xo' ) , undefined ) ;
38
37
} ) ;
39
38
40
39
test ( 'has default test' , async t => {
@@ -44,8 +43,8 @@ test('has default test', async t => {
44
43
} ,
45
44
} ) ;
46
45
47
- t . is ( get ( pkg , 'scripts.test' ) , 'xo' ) ;
48
- t . is ( get ( pkg , 'xo' ) , undefined ) ;
46
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo' ) ;
47
+ t . is ( getProperty ( pkg , 'xo' ) , undefined ) ;
49
48
} ) ;
50
49
51
50
test ( 'has only xo' , async t => {
@@ -55,8 +54,8 @@ test('has only xo', async t => {
55
54
} ,
56
55
} ) ;
57
56
58
- t . is ( get ( pkg , 'scripts.test' ) , 'xo' ) ;
59
- t . is ( get ( pkg , 'xo' ) , undefined ) ;
57
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo' ) ;
58
+ t . is ( getProperty ( pkg , 'xo' ) , undefined ) ;
60
59
} ) ;
61
60
62
61
test ( 'has test' , async t => {
@@ -66,8 +65,8 @@ test('has test', async t => {
66
65
} ,
67
66
} ) ;
68
67
69
- t . is ( get ( pkg , 'scripts.test' ) , 'xo && ava' ) ;
70
- t . is ( get ( pkg , 'xo' ) , undefined ) ;
68
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo && ava' ) ;
69
+ t . is ( getProperty ( pkg , 'xo' ) , undefined ) ;
71
70
} ) ;
72
71
73
72
test ( 'has cli args' , async t => {
@@ -80,8 +79,8 @@ test('has cli args', async t => {
80
79
} ) ;
81
80
82
81
process . argv = originalArgv ;
83
- t . is ( get ( pkg , 'scripts.test' ) , 'xo' ) ;
84
- t . is ( get ( pkg , 'xo.space' ) , true ) ;
82
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo' ) ;
83
+ t . is ( getProperty ( pkg , 'xo.space' ) , true ) ;
85
84
} ) ;
86
85
87
86
test ( 'has cli args and test' , async t => {
@@ -94,9 +93,9 @@ test('has cli args and test', async t => {
94
93
} ) ;
95
94
96
95
process . argv = originalArgv ;
97
- t . is ( get ( pkg , 'scripts.test' ) , 'xo && ava' ) ;
98
- t . is ( get ( pkg , 'xo.envs.0 ' ) , 'node' ) ;
99
- t . is ( get ( pkg , 'xo.envs.1 ' ) , 'browser' ) ;
96
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo && ava' ) ;
97
+ t . is ( getProperty ( pkg , 'xo.envs[0] ' ) , 'node' ) ;
98
+ t . is ( getProperty ( pkg , 'xo.envs[1] ' ) , 'browser' ) ;
100
99
} ) ;
101
100
102
101
test ( 'has cli args and existing config' , async t => {
@@ -109,9 +108,9 @@ test('has cli args and existing config', async t => {
109
108
} ) ;
110
109
111
110
process . argv = originalArgv ;
112
- t . is ( get ( pkg , 'scripts.test' ) , 'xo' ) ;
113
- t . is ( get ( pkg , 'xo.space' ) , true ) ;
114
- t . is ( get ( pkg , 'xo.esnext' ) , true ) ;
111
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo' ) ;
112
+ t . is ( getProperty ( pkg , 'xo.space' ) , true ) ;
113
+ t . is ( getProperty ( pkg , 'xo.esnext' ) , true ) ;
115
114
} ) ;
116
115
117
116
test ( 'has existing config without cli args' , async t => {
@@ -124,12 +123,13 @@ test('has existing config without cli args', async t => {
124
123
} ) ;
125
124
126
125
process . argv = originalArgv ;
127
- t . is ( get ( pkg , 'scripts.test' ) , 'xo' ) ;
128
- t . deepEqual ( get ( pkg , 'xo' ) , { esnext : true } ) ;
126
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo' ) ;
127
+ t . deepEqual ( getProperty ( pkg , 'xo' ) , { esnext : true } ) ;
129
128
} ) ;
130
129
131
130
test ( 'has everything covered when it comes to config' , async t => {
132
- process . argv = [ ...originalArgv ,
131
+ process . argv = [
132
+ ...originalArgv ,
133
133
'--space' ,
134
134
'--esnext' ,
135
135
'--no-semicolon' ,
@@ -138,27 +138,28 @@ test('has everything covered when it comes to config', async t => {
138
138
'--global=foo' ,
139
139
'--global=bar' ,
140
140
'--ignore=foo' ,
141
- '--ignore=bar' ] ;
141
+ '--ignore=bar' ,
142
+ ] ;
142
143
143
144
const pkg = await run ( { } ) ;
144
145
145
146
process . argv = originalArgv ;
146
- t . is ( get ( pkg , 'scripts.test' ) , 'xo' ) ;
147
- t . is ( get ( pkg , 'xo.space' ) , true ) ;
148
- t . is ( get ( pkg , 'xo.esnext' ) , true ) ;
149
- t . is ( get ( pkg , 'xo.semicolon' ) , false ) ;
150
- t . is ( get ( pkg , 'xo.envs.0 ' ) , 'foo' ) ;
151
- t . is ( get ( pkg , 'xo.envs.1 ' ) , 'bar' ) ;
152
- t . is ( get ( pkg , 'xo.globals.0 ' ) , 'foo' ) ;
153
- t . is ( get ( pkg , 'xo.globals.1 ' ) , 'bar' ) ;
154
- t . is ( get ( pkg , 'xo.ignores.0 ' ) , 'foo' ) ;
155
- t . is ( get ( pkg , 'xo.ignores.1 ' ) , 'bar' ) ;
147
+ t . is ( getProperty ( pkg , 'scripts.test' ) , 'xo' ) ;
148
+ t . is ( getProperty ( pkg , 'xo.space' ) , true ) ;
149
+ t . is ( getProperty ( pkg , 'xo.esnext' ) , true ) ;
150
+ t . is ( getProperty ( pkg , 'xo.semicolon' ) , false ) ;
151
+ t . is ( getProperty ( pkg , 'xo.envs[0] ' ) , 'foo' ) ;
152
+ t . is ( getProperty ( pkg , 'xo.envs[1] ' ) , 'bar' ) ;
153
+ t . is ( getProperty ( pkg , 'xo.globals[0] ' ) , 'foo' ) ;
154
+ t . is ( getProperty ( pkg , 'xo.globals[1] ' ) , 'bar' ) ;
155
+ t . is ( getProperty ( pkg , 'xo.ignores[0] ' ) , 'foo' ) ;
156
+ t . is ( getProperty ( pkg , 'xo.ignores[1] ' ) , 'bar' ) ;
156
157
} ) ;
157
158
158
159
test ( 'installs the XO dependency' , async t => {
159
160
const filepath = tempWrite . sync ( JSON . stringify ( { } ) , 'package.json' ) ;
160
161
await createXo ( { cwd : path . dirname ( filepath ) } ) ;
161
- t . truthy ( get ( JSON . parse ( fs . readFileSync ( filepath , 'utf8' ) ) , 'devDependencies.xo' ) ) ;
162
+ t . truthy ( getProperty ( JSON . parse ( fs . readFileSync ( filepath , 'utf8' ) ) , 'devDependencies.xo' ) ) ;
162
163
} ) ;
163
164
164
165
test ( 'installs via yarn if there\'s a lockfile' , async t => {
0 commit comments