@@ -2,7 +2,56 @@ import assert from "assert";
2
2
import fs from "fs" ;
3
3
import path from "path" ;
4
4
import os from "os" ;
5
- import { updateOrCreateGitignore } from "./index" ;
5
+ import { getBuildOptions , updateOrCreateGitignore } from "./index" ;
6
+
7
+ const originalCwd = process . cwd . bind ( process ) ;
8
+
9
+ describe ( "get a set of 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
+ const expectedOptions = {
30
+ buildCommand : "turbo" ,
31
+ buildArgs : [ "run" , "build" , "--filter=web" , "--env-mode=strict" ] ,
32
+ projectDirectory : "/workspace/apps/web" ,
33
+ projectName : "web" ,
34
+ } ;
35
+ assert . deepStrictEqual (
36
+ getBuildOptions ( ) ,
37
+ expectedOptions ,
38
+ "Monorepo build options are incorrect" ,
39
+ ) ;
40
+ } ) ;
41
+
42
+ it ( "returns standard build options when MONOREPO_COMMAND is not set" , ( ) => {
43
+ const expectedOptions = {
44
+ buildCommand : "npm" ,
45
+ buildArgs : [ "run" , "build" ] ,
46
+ projectDirectory : process . cwd ( ) ,
47
+ } ;
48
+ assert . deepStrictEqual (
49
+ getBuildOptions ( ) ,
50
+ expectedOptions ,
51
+ "Standard build options are incorrect" ,
52
+ ) ;
53
+ } ) ;
54
+ } ) ;
6
55
7
56
describe ( "update or create .gitignore" , ( ) => {
8
57
let tmpDir : string ;
0 commit comments