@@ -2,7 +2,50 @@ import assert from "assert";
22import fs from "fs" ;
33import path from "path" ;
44import os from "os" ;
5- import { updateOrCreateGitignore } from "./index" ;
5+ import { getBuildOptions , updateOrCreateGitignore } from "./index" ;
6+
7+ const originalCwd = process . cwd ;
8+
9+ describe ( "get a set of default build options" , ( ) => {
10+ const mockCwd = '/fake/project/' ;
11+ beforeEach ( ( ) => {
12+ process . cwd = ( ) => mockCwd ;
13+ } )
14+
15+ afterEach ( ( ) => {
16+ process . cwd = originalCwd ;
17+ delete process . env . MONOREPO_COMMAND ;
18+ delete process . env . MONOREPO_BUILD_ARGS ;
19+ delete process . env . GOOGLE_BUILDABLE ;
20+ delete process . env . MONOREPO_PROJECT ;
21+ } ) ;
22+
23+ it ( 'returns monorepo build options when MONOREPO_COMMAND is set' , ( ) => {
24+ process . env . MONOREPO_COMMAND = 'turbo' ;
25+ process . env . MONOREPO_BUILD_ARGS = '--filter=web,--env-mode=strict' ;
26+ process . env . GOOGLE_BUILDABLE = '/workspace/apps/web' ;
27+ process . env . MONOREPO_PROJECT = 'web' ;
28+
29+ // Assert that the returned options are correct
30+ const expectedOptions = {
31+ buildCommand : 'turbo' ,
32+ buildArgs : [ 'run' , 'build' , '--filter=web' , '--env-mode=strict' ] ,
33+ projectDirectory : '/workspace/apps/web' ,
34+ projectName : 'web' ,
35+ } ;
36+ assert . deepStrictEqual ( getBuildOptions ( ) , expectedOptions , 'Monorepo build options are incorrect' ) ;
37+ } ) ;
38+
39+ it ( 'returns standard build options when MONOREPO_COMMAND is not set' , ( ) => {
40+ const expectedOptions = {
41+ buildCommand : 'npm' ,
42+ buildArgs : [ 'run' , 'build' ] ,
43+ projectDirectory : process . cwd ( ) ,
44+ } ;
45+ assert . deepStrictEqual ( getBuildOptions ( ) , expectedOptions , 'Standard build options are incorrect' ) ;
46+ } ) ;
47+ } ) ;
48+
649
750describe ( "update or create .gitignore" , ( ) => {
851 let tmpDir : string ;
0 commit comments