1- import { execSync } from 'node:child_process' ;
21import path from 'node:path' ;
32import { describe , expect , test } from '@rstest/core' ;
43import fse from 'fs-extra' ;
5- import { buildAndGetResults , globContentJSON } from 'test-helper' ;
4+ import { buildAndGetResults , globContentJSON , runCliSync } from 'test-helper' ;
65
76describe ( 'build command' , async ( ) => {
87 test ( 'basic' , async ( ) => {
98 await fse . remove ( path . join ( __dirname , 'dist' ) ) ;
10- execSync ( 'npx rslib build', {
9+ runCliSync ( ' build', {
1110 cwd : __dirname ,
1211 } ) ;
1312
@@ -23,7 +22,7 @@ describe('build command', async () => {
2322
2423 test ( '--lib' , async ( ) => {
2524 await fse . remove ( path . join ( __dirname , 'dist' ) ) ;
26- execSync ( 'npx rslib build --lib esm', {
25+ runCliSync ( ' build --lib esm', {
2726 cwd : __dirname ,
2827 } ) ;
2928
@@ -38,7 +37,7 @@ describe('build command', async () => {
3837
3938 test ( '--lib multiple' , async ( ) => {
4039 await fse . remove ( path . join ( __dirname , 'dist' ) ) ;
41- execSync ( 'npx rslib build --lib esm --lib cjs', {
40+ runCliSync ( ' build --lib esm --lib cjs', {
4241 cwd : __dirname ,
4342 } ) ;
4443
@@ -69,12 +68,9 @@ describe('build command', async () => {
6968
7069 test ( '--config' , async ( ) => {
7170 await fse . remove ( path . join ( __dirname , 'dist' ) ) ;
72- execSync (
73- 'npx rslib build --config ./custom-config/rslib.config.custom.ts' ,
74- {
75- cwd : __dirname ,
76- } ,
77- ) ;
71+ runCliSync ( 'build --config ./custom-config/rslib.config.custom.ts' , {
72+ cwd : __dirname ,
73+ } ) ;
7874
7975 const files = await globContentJSON ( path . join ( __dirname , 'dist' ) ) ;
8076 const fileNames = Object . keys ( files ) . sort ( ) ;
@@ -88,7 +84,7 @@ describe('build command', async () => {
8884
8985 test ( '--root' , async ( ) => {
9086 await fse . remove ( path . join ( __dirname , 'dist' ) ) ;
91- execSync ( 'npx rslib build --root custom-root', {
87+ runCliSync ( ' build --root custom-root', {
9288 cwd : __dirname ,
9389 } ) ;
9490
0 commit comments