1
- const { relative, resolve, join } = require ( "path" ) ;
2
- const { closeSync, openSync, writeFileSync } = require ( "fs" ) ;
1
+ const { relative, resolve, join, dirname } = require ( "path" ) ;
2
+ const { closeSync, openSync, writeFileSync, existsSync , mkdirSync } = require ( "fs" ) ;
3
3
const validateOptions = require ( "schema-utils" ) ;
4
4
5
5
const ProjectSnapshotGenerator = require ( "../../snapshot/android/project-snapshot-generator" ) ;
@@ -57,6 +57,7 @@ exports.NativeScriptSnapshotPlugin = (function () {
57
57
snapshotEntryContent += [ ...requireModules , ...internalRequireModules ]
58
58
. map ( mod => `require('${ mod } ')` ) . join ( ";" ) ;
59
59
60
+ ensureDirectoryExistence ( snapshotEntryPath ) ;
60
61
writeFileSync ( snapshotEntryPath , snapshotEntryContent , { encoding : "utf8" } ) ;
61
62
62
63
// add the module to the entry points to make sure it's content is evaluated
@@ -69,6 +70,15 @@ exports.NativeScriptSnapshotPlugin = (function () {
69
70
webpackConfig . optimization . runtimeChunk = { name : SNAPSHOT_ENTRY_NAME } ;
70
71
}
71
72
73
+ function ensureDirectoryExistence ( filePath ) {
74
+ var dir = dirname ( filePath ) ;
75
+ if ( existsSync ( dir ) ) {
76
+ return true ;
77
+ }
78
+ ensureDirectoryExistence ( dir ) ;
79
+ mkdirSync ( dir ) ;
80
+ }
81
+
72
82
NativeScriptSnapshotPlugin . getInternalRequireModules = function ( webpackContext ) {
73
83
const packageJson = getPackageJson ( webpackContext ) ;
74
84
return ( packageJson && packageJson [ "android" ] && packageJson [ "android" ] [ "requireModules" ] ) || [ ] ;
0 commit comments