1
- 'use strict'
1
+ 'use strict' ;
2
2
var path = require ( 'path' ) ;
3
3
var fs = require ( 'fs' ) ;
4
-
4
+
5
5
module . exports = function ( hookArgs , $logger , $projectData ) {
6
- const platform = ( hookArgs . platform || hookArgs . prepareData . platform ) . toLowerCase ( ) ;
7
- // console.log('preparing platform:', platform);
8
- const packagePath = $projectData . projectFilePath ;
6
+ const platform = ( hookArgs . platform || hookArgs . prepareData . platform ) . toLowerCase ( ) ;
7
+ // console.log('preparing platform:', platform);
8
+ const pack
10000
agePath = $projectData . projectFilePath ;
9
+
10
+ const ionicPortalName = 'ionicWebPortalSample' ;
11
+ const configAppResourcesPath = path . join ( packagePath , '../../../tools/assets' , ionicPortalName ) ;
12
+ console . log ( 'configAppResourcesPath:' , configAppResourcesPath ) ;
13
+
14
+ return new Promise ( function ( resolve , reject ) {
15
+ try {
16
+ //copy files
17
+ const resourcesPath = path . join ( packagePath , '../../../tools/assets/App_Resources' , platform === 'ios' ? 'iOS' : 'Android/src/main/assets' ) ;
18
+ const copyRecursive = ( contents , subPath = '' ) => {
19
+ contents . forEach ( function ( contentPath ) {
20
+ const fullFilePath = path . join ( configAppResourcesPath , subPath , contentPath ) ;
21
+ // console.log('fullFilePath:', fullFilePath)
22
+ const filePath = fullFilePath . split ( 'tools' + path . sep + 'assets' ) [ 1 ] ;
23
+ if ( fs . lstatSync ( fullFilePath ) . isDirectory ( ) ) {
24
+ if ( filePath ) {
25
+ const copyToFolder = path . join ( resourcesPath , filePath ) ;
26
+ if ( ! fs . existsSync ( copyToFolder ) ) {
27
+ fs . mkdirSync ( copyToFolder ) ;
28
+ }
29
+ }
30
+ copyRecursive ( fs . readdirSync ( fullFilePath ) , ( subPath ? subPath + path . sep : '' ) + contentPath ) ;
31
+ } else {
32
+ const filePath = fullFilePath . split ( 'tools' + path . sep + 'assets' ) [ 1 ] ;
9
33
10
- const ionicPortalName = 'ionicWebPortalSample' ;
11
- const configAppResourcesPath = path . join ( packagePath , '../../../tools/assets' , ionicPortalName ) ;
12
- console . log ( 'configAppResourcesPath:' , configAppResourcesPath )
13
-
14
- return new Promise ( function ( resolve , reject ) {
15
- try {
16
- //copy files
17
- const resourcesPath = path . join ( packagePath , '../../../tools/assets/App_Resources' , platform === 'ios' ? 'iOS' : 'Android/src/main/assets' ) ;
18
- const copyRecursive = ( contents , subPath = '' ) => {
19
- contents . forEach ( function ( contentPath ) {
20
- const fullFilePath = path . join ( configAppResourcesPath , subPath , contentPath ) ;
21
- // console.log('fullFilePath:', fullFilePath)
22
- const filePath = fullFilePath . split ( 'tools/assets' ) [ 1 ] ;
23
- if ( fs . lstatSync ( fullFilePath ) . isDirectory ( ) ) {
24
- if ( filePath ) {
25
- const copyToFolder = path . join ( resourcesPath , filePath ) ;
26
- if ( ! fs . existsSync ( copyToFolder ) ) {
27
- fs . mkdirSync ( copyToFolder ) ;
28
- }
29
- }
30
- copyRecursive ( fs . readdirSync ( fullFilePath ) , ( subPath ? subPath + '/' : '' ) + contentPath ) ;
31
- } else {
32
- const filePath = fullFilePath . split ( 'tools/assets' ) [ 1 ] ;
33
- if ( filePath ) {
34
- const copyTo = path . join ( resourcesPath , filePath ) ;
35
- // console.log('copy from:', fullFilePath);
36
- // console.log('to:', copyTo)
37
- fs . writeFileSync ( copyTo , fs . readFileSync ( fullFilePath ) ) ;
38
- } else {
39
- copyRecursive ( fs . readdirSync ( fullFilePath ) , contentPath ) ;
40
- }
41
- }
42
- } ) ;
43
- } ;
44
- const portalFolderPath = path . join ( resourcesPath , ionicPortalName ) ;
45
- if ( ! fs . existsSync ( portalFolderPath ) ) {
46
- fs . mkdirSync ( portalFolderPath ) ;
47
- }
48
- const contents = fs . readdirSync ( configAppResourcesPath ) ;
49
- copyRecursive ( contents ) ;
34
+ if ( filePath ) {
35
+ const copyTo = path . join ( resourcesPath , filePath ) ;
36
+ // console.log('copy from:', fullFilePath);
37
+ // console.log('to:', copyTo)
38
+ fs . writeFileSync ( copyTo , fs . readFileSync ( fullFilePath ) ) ;
39
+ } else {
40
+ copyRecursive ( fs . readdirSync ( fullFilePath ) , contentPath ) ;
41
+ }
42
+ }
43
+ } ) ;
44
+ } ;
45
+ const portalFolderPath = path . join ( resourcesPath , ionicPortalName ) ;
46
+ if ( ! fs . existsSync ( portalFolderPath ) ) {
47
+ fs . mkdirSync ( portalFolderPath ) ;
48
+ }
49
+ const contents = fs . readdirSync ( configAppResourcesPath ) ;
50
+ copyRecursive ( contents ) ;
50
51
51
- resolve ( ) ;
52
- } catch ( err ) {
53
- reject ( err )
54
- }
55
- } ) ;
56
- } ;
52
+ resolve ( ) ;
53
+ } catch ( err ) {
54
+ reject ( err ) ;
55
+ }
56
+ } ) ;
57
+ } ;
0 commit comments