File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
packages/load-application Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @serverless-devs/load-application" ,
3- "version" : " 0.0.15 " ,
3+ "version" : " 0.0.16-beta.1 " ,
44 "description" : " load application for serverless-devs" ,
55 "main" : " lib/index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -95,13 +95,35 @@ class LoadApplication {
9595 * 7. 解析 s.yaml里的 name 字段
9696 */
9797 this . parseAppName ( templateData as string ) ;
98+ /**
99+ * 8. 解析目录下所有后缀为.stpl的文件
100+ */
101+ await this . parseStpl ( this . filePath ) ;
98102 /**
99- * 8 . 最后的动作, 比如:删除临时文件夹
103+ * 9 . 最后的动作, 比如:删除临时文件夹
100104 */
101105 await this . final ( ) ;
102106 return this . filePath ;
103107 }
104108
109+ // art-template解析目录下所有后缀为.stpl的文件
110+ private async parseStpl ( dirPath : string ) {
111+ const allFiles = fs . readdirSync ( dirPath ) ;
112+ for ( const file of allFiles ) {
113+ if ( fs . statSync ( path . join ( dirPath , file ) ) . isDirectory ( ) ) {
114+ await this . parseStpl ( path . join ( dirPath , file ) ) ;
115+ continue ;
116+ }
117+ if ( file . endsWith ( '.stpl' ) ) {
118+ const filePath = path . join ( dirPath , file ) ;
119+ const newData = this . doArtTemplate ( filePath ) ;
120+ fs . writeFileSync ( filePath , newData , 'utf-8' ) ;
121+ // 删除.stpl后缀
122+ fs . renameSync ( filePath , filePath . replace ( '.stpl' , '' ) ) ;
123+ }
124+ }
125+ }
126+
105127 private async check ( ) {
106128 if ( this . options . y ) return true ;
107129 if ( isCiCdEnvironment ( ) ) return true ;
You can’t perform that action at this time.
0 commit comments