@@ -13,6 +13,9 @@ import {
1313 spinner ,
1414 stopSpinner ,
1515} from '../utils.js' ;
16+ import { Conf } from '../conf.js' ;
17+
18+ const config = Conf . get ( ) ;
1619
1720interface CommandOption {
1821 readonly parentId ?: string ;
@@ -30,10 +33,14 @@ interface CommandOption {
3033 * If not specified, clasp will default to the current directory.
3134 */
3235export default async ( options : CommandOption ) : Promise < void > => {
36+ if ( options . rootDir ) {
37+ config . projectRootDirectory = options . rootDir ;
38+ }
39+
3340 // Handle common errors.
3441 await checkIfOnlineOrDie ( ) ;
3542 if ( hasProject ( ) ) {
36- throw new ClaspError ( ERROR . FOLDER_EXISTS ) ;
43+ throw new ClaspError ( ERROR . FOLDER_EXISTS ( ) ) ;
3744 }
3845
3946 await loadAPICredentials ( ) ;
@@ -98,10 +105,12 @@ export default async (options: CommandOption): Promise<void> => {
98105
99106 const scriptId = data . scriptId ?? '' ;
100107 console . log ( LOG . CREATE_PROJECT_FINISH ( filetype , scriptId ) ) ;
101- const { rootDir} = options ;
102- await saveProject ( { scriptId, rootDir, parentId : parentId ? [ parentId ] : undefined } , false ) ;
108+ await saveProject (
109+ { scriptId, rootDir : config . projectRootDirectory , parentId : parentId ? [ parentId ] : undefined } ,
110+ false
111+ ) ;
103112
104- if ( ! manifestExists ( rootDir ) ) {
105- await writeProjectFiles ( await fetchProject ( scriptId ) , rootDir ) ; // Fetches appsscript.json, o.w. `push` breaks
113+ if ( ! manifestExists ( config . projectRootDirectory ) ) {
114+ await writeProjectFiles ( await fetchProject ( scriptId ) , config . projectRootDirectory ) ; // Fetches appsscript.json, o.w. `push` breaks
106115 }
107116} ;
0 commit comments