@@ -3,38 +3,26 @@ const fs = require("fs");
33
44const { isTypeScript, isAngular } = require ( "./projectHelpers" ) ;
55
6- function addProjectFiles ( projectDir , appDir ) {
6+ function addProjectFiles ( projectDir ) {
77 const projectTemplates = getProjectTemplates ( projectDir ) ;
88 Object . keys ( projectTemplates ) . forEach ( function ( templateName ) {
99 const templateDestination = projectTemplates [ templateName ] ;
1010 templateName = path . resolve ( templateName ) ;
1111 copyTemplate ( templateName , templateDestination ) ;
1212 } ) ;
13-
14- const appTemplates = getAppTemplates ( projectDir , appDir ) ;
15- Object . keys ( appTemplates ) . forEach ( function ( templateName ) {
16- const templateDestination = appTemplates [ templateName ] ;
17- copyTemplate ( templateName , templateDestination )
18- } ) ;
1913}
2014
21- function removeProjectFiles ( projectDir , appDir ) {
15+ function removeProjectFiles ( projectDir ) {
2216 const projectTemplates = getProjectTemplates ( projectDir ) ;
2317 Object . keys ( projectTemplates ) . forEach ( function ( templateName ) {
2418 const templateDestination = projectTemplates [ templateName ] ;
2519 deleteFile ( templateDestination ) ;
2620 } ) ;
27-
28- const appTemplates = getAppTemplates ( projectDir , appDir ) ;
29- Object . keys ( appTemplates ) . forEach ( function ( templateName ) {
30- const templateDestination = appTemplates [ templateName ] ;
31- deleteFile ( templateDestination ) ;
32- } ) ;
3321}
3422
35- function forceUpdateProjectFiles ( projectDir , appDir ) {
36- removeProjectFiles ( projectDir , appDir ) ;
37- addProjectFiles ( projectDir , appDir ) ;
23+ function forceUpdateProjectFiles ( projectDir ) {
24+ removeProjectFiles ( projectDir ) ;
25+ addProjectFiles ( projectDir ) ;
3826}
3927
4028function compareProjectFiles ( projectDir ) {
@@ -69,31 +57,20 @@ function copyTemplate(templateName, destinationPath) {
6957}
7058
7159function getProjectTemplates ( projectDir ) {
72- let templates = { }
60+ const templates = { }
61+ const CONFIG_NAME = "webpack.config.js" ;
7362
7463 if ( isAngular ( { projectDir} ) ) {
75- templates [ "webpack.angular.js" ] = "webpack.config.js" ;
64+ templates [ "webpack.angular.js" ] = CONFIG_NAME ;
7665 } else if ( isTypeScript ( { projectDir} ) ) {
77- templates [ "webpack.typescript.js" ] = "webpack.config.js" ;
66+ templates [ "webpack.typescript.js" ] = CONFIG_NAME ;
7867 } else {
79- templates [ "webpack.javascript.js" ] = "webpack.config.js" ;
68+ templates [ "webpack.javascript.js" ] = CONFIG_NAME ;
8069 }
8170
8271 return getFullTemplatesPath ( projectDir , templates ) ;
8372}
8473
85- function getAppTemplates ( projectDir , appDir ) {
86- const templates = { } ;
87-
88- if ( isAngular ( { projectDir} ) ) {
89- templates [ "vendor.angular.ts" ] = tsOrJs ( projectDir , "vendor" ) ;
90- } else {
91- templates [ "vendor.nativescript.ts" ] = tsOrJs ( projectDir , "vendor" ) ;
92- }
93-
94- return getFullTemplatesPath ( appDir , templates ) ;
95- }
96-
9774function getFullTemplatesPath ( projectDir , templates ) {
9875 let updatedTemplates = { } ;
9976
@@ -111,15 +88,9 @@ function getFullPath(projectDir, filePath) {
11188 return path . resolve ( projectDir , filePath ) ;
11289}
11390
114- function tsOrJs ( projectDir , name ) {
115- const extension = isTypeScript ( { projectDir} ) ? "ts" : "js" ;
116- return `${ name } .${ extension } ` ;
117- }
118-
11991module . exports = {
12092 addProjectFiles,
12193 removeProjectFiles,
12294 forceUpdateProjectFiles,
12395 compareProjectFiles,
12496} ;
125-
0 commit comments