@@ -9,6 +9,7 @@ import path from 'path';
99import fs from 'node:fs/promises' ;
1010import { existsSync } from 'fs' ;
1111import toml from '@iarna/toml' ;
12+ import { exec } from 'child_process' ;
1213
1314async function expandLiquidTemplates ( template , liquidData ) {
1415 const entries = await glob ( [ path . join ( template , "**/*.liquid" ) ] , {
@@ -106,6 +107,26 @@ async function expandExtensionLiquidTemplates(domainName, flavor) {
106107 console . log ( ) ;
107108}
108109
110+ function ensureNoGitChanges ( ) {
111+ exec ( 'git status --porcelain' , ( error , stdout , _stderr ) => {
112+ if ( error ) {
113+ console . error ( `error calling \`git status\`: ${ error } ` ) ;
114+ process . exit ( 1 ) ; ;
115+ }
116+ if ( stdout ) {
117+ console . error ( 'Untracked files detected:\n' , stdout ) ;
118+ exec ( 'git diff' , ( error , stdout , _stderr ) => {
119+ if ( error ) {
120+ console . error ( `error calling \`git diff\`: ${ error } ` ) ;
121+ } else {
122+ console . log ( `Git diff:\n${ stdout } ` ) ;
123+ }
124+ process . exit ( 1 ) ;
125+ } ) ;
126+ }
127+ } ) ;
128+ }
129+
109130const flavor = process . argv [ 2 ] || "vanilla-js" ;
110131
111132const SAMPLE_APP_DIR = 'sample-apps' ;
@@ -116,4 +137,8 @@ for (const domain of DOMAINS) {
116137 await expandExtensionLiquidTemplates ( domain , flavor ) ;
117138}
118139
119- console . log ( 'The above files should be added to .gitignore if they have not already been added.' ) ;
140+ console . log ( 'The above files should be added to .gitignore if they have not already been added.\n' ) ;
141+
142+ if ( process . env . CI ) {
143+ ensureNoGitChanges ( ) ;
144+ }
0 commit comments