This repository was archived by the owner on Aug 7, 2021. It is now read-only.
File tree 3 files changed +21
-3
lines changed
plugins/NativeScriptSnapshotPlugin
3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ module.exports = function (hookArgs) {
12
12
release : hookArgs . prepareData . release
13
13
} ;
14
14
15
- if ( env . snapshot && shouldSnapshot ( shouldSnapshotOptions ) ) {
15
+ if ( env . snapshot &&
16
+ shouldSnapshot ( shouldSnapshotOptions ) &&
17
+ ( ! hookArgs . prepareData ||
18
+ ! hookArgs . prepareData . nativePrepare ||
19
+ ! hookArgs . prepareData . nativePrepare . skipNativePrepare ) ) {
20
+
16
21
installSnapshotArtefacts ( hookArgs . prepareData . projectDir ) ;
17
22
}
18
23
}
Original file line number Diff line number Diff line change 1
1
const os = require ( "os" ) ;
2
+ const { dirname } = require ( "path" ) ;
3
+ const { existsSync, mkdirSync } = require ( "fs" ) ;
2
4
const { isAndroid } = require ( "../projectHelpers" ) ;
3
5
4
6
function shouldSnapshot ( config ) {
@@ -21,9 +23,19 @@ function warn(message) {
21
23
}
22
24
}
23
25
26
+ function ensureDirectoryExistence ( filePath ) {
27
+ var dir = dirname ( filePath ) ;
28
+ if ( existsSync ( dir ) ) {
29
+ return true ;
30
+ }
31
+ ensureDirectoryExistence ( dir ) ;
32
+ mkdirSync ( dir ) ;
33
+ }
34
+
24
35
module . exports = {
25
36
shouldSnapshot,
26
37
convertToUnixPath,
27
38
isWinOS,
28
- warn
39
+ warn,
40
+ ensureDirectoryExistence
29
41
} ;
Original file line number Diff line number Diff line change 8
8
ANDROID_PROJECT_DIR ,
9
9
ANDROID_APP_PATH ,
10
10
} = require ( "../../androidProjectHelpers" ) ;
11
+ const { ensureDirectoryExistence } = require ( "../../lib/utils" ) ;
11
12
const schema = require ( "./options.json" ) ;
12
13
13
14
const SNAPSHOT_ENTRY_NAME = "snapshot-entry" ;
@@ -57,6 +58,7 @@ exports.NativeScriptSnapshotPlugin = (function () {
57
58
snapshotEntryContent += [ ...requireModules , ...internalRequireModules ]
58
59
. map ( mod => `require('${ mod } ')` ) . join ( ";" ) ;
59
60
61
+ ensureDirectoryExistence ( snapshotEntryPath ) ;
60
62
writeFileSync ( snapshotEntryPath , snapshotEntryContent , { encoding : "utf8" } ) ;
61
63
62
64
// add the module to the entry points to make sure it's content is evaluated
@@ -68,7 +70,6 @@ exports.NativeScriptSnapshotPlugin = (function () {
68
70
// ensure that the runtime is installed only in the snapshotted chunk
69
71
webpackConfig . optimization . runtimeChunk = { name : SNAPSHOT_ENTRY_NAME } ;
70
72
}
71
-
72
73
NativeScriptSnapshotPlugin . getInternalRequireModules = function ( webpackContext ) {
73
74
const packageJson = getPackageJson ( webpackContext ) ;
74
75
return ( packageJson && packageJson [ "android" ] && packageJson [ "android" ] [ "requireModules" ] ) || [ ] ;
You can’t perform that action at this time.
0 commit comments