You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org> on 2024/04/17 06:03:54 UTC
Re: [PR] refactor: use node internal modules & replace fs-extra with node:fs [cordova-electron]
github-advanced-security[bot] commented on code in PR #273:
URL: https://github.com/apache/cordova-electron/pull/273#discussion_r1568270040
##########
lib/PackageJsonParser.js:
##########
@@ -17,15 +17,24 @@
under the License.
*/
-const fs = require('fs-extra');
-const path = require('path');
+const fs = require('node:fs');
+const path = require('node:path');
const { getPackageJson } = require('./util');
class PackageJsonParser {
constructor (wwwDir, projectRootDir) {
- // Electron App Package
+ // make sure www dir exists
+ if (!fs.existsSync(wwwDir)) {
+ fs.mkdirSync(wwwDir, { recursive: true });
+ }
+
this.path = path.join(wwwDir, 'package.json');
- fs.ensureFileSync(this.path);
+
+ if (!fs.existsSync(this.path)) {
+ fs.writeFileSync(this.path, '{}', 'utf8');
Review Comment:
## Potential file system race condition
The file may have changed since it [was checked](1).
[Show more details](https://github.com/apache/cordova-electron/security/code-scanning/1)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org