Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 2a0eaf6

Browse files
committed
fix: ensure the js snapshot entry dir if not created (avoid ENOENT error)
1 parent 53cac58 commit 2a0eaf6

File tree

1 file changed

+12
-2
lines changed
  • plugins/NativeScriptSnapshotPlugin

1 file changed

+12
-2
lines changed

plugins/NativeScriptSnapshotPlugin/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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");
33
const validateOptions = require("schema-utils");
44

55
const ProjectSnapshotGenerator = require("../../snapshot/android/project-snapshot-generator");
@@ -57,6 +57,7 @@ exports.NativeScriptSnapshotPlugin = (function () {
5757
snapshotEntryContent += [...requireModules, ...internalRequireModules]
5858
.map(mod => `require('${mod}')`).join(";");
5959

60+
ensureDirectoryExistence(snapshotEntryPath);
6061
writeFileSync(snapshotEntryPath, snapshotEntryContent, { encoding: "utf8" });
6162

6263
// add the module to the entry points to make sure it's content is evaluated
@@ -69,6 +70,15 @@ exports.NativeScriptSnapshotPlugin = (function () {
6970
webpackConfig.optimization.runtimeChunk = { name: SNAPSHOT_ENTRY_NAME };
7071
}
7172

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+
7282
NativeScriptSnapshotPlugin.getInternalRequireModules = function (webpackContext) {
7383
const packageJson = getPackageJson(webpackContext);
7484
return (packageJson && packageJson["android"] && packageJson["android"]["requireModules"]) || [];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy