refactor: replace fs-extra with node:fs (#1772)

* spec: add devDependencies "tmp"
This commit is contained in:
エリス
2025-01-29 10:39:11 +09:00
committed by GitHub
parent b623311efa
commit e012478537
20 changed files with 188 additions and 164 deletions
+7 -7
View File
@@ -17,7 +17,7 @@
under the License.
*/
const fs = require('fs-extra');
const fs = require('node:fs');
const path = require('node:path');
const execa = require('execa');
const glob = require('fast-glob');
@@ -174,7 +174,7 @@ class ProjectBuilder {
try {
fs.accessSync(subProjectGradle, fs.F_OK);
} catch (e) {
fs.copySync(pluginBuildGradle, subProjectGradle);
fs.cpSync(pluginBuildGradle, subProjectGradle);
}
};
@@ -207,7 +207,7 @@ class ProjectBuilder {
settingsGradlePaths.join(''));
// Touch empty cdv-gradle-name.gradle file if missing.
if (!fs.pathExistsSync(path.join(this.root, 'cdv-gradle-name.gradle'))) {
if (!fs.existsSync(path.join(this.root, 'cdv-gradle-name.gradle'))) {
fs.writeFileSync(path.join(this.root, 'cdv-gradle-name.gradle'), '');
}
@@ -294,7 +294,7 @@ class ProjectBuilder {
}).then(() => {
const signingPropertiesPath = path.join(self.root, `${opts.buildType}${SIGNING_PROPERTIES}`);
if (fs.existsSync(signingPropertiesPath)) fs.removeSync(signingPropertiesPath);
if (fs.existsSync(signingPropertiesPath)) fs.rmSync(signingPropertiesPath);
if (opts.packageInfo) {
fs.ensureFileSync(signingPropertiesPath);
const signingProperties = createEditor(signingPropertiesPath);
@@ -309,7 +309,7 @@ class ProjectBuilder {
* @returns The user defined configs
*/
_getCordovaConfig () {
return fs.readJSONSync(path.join(this.root, 'cdv-gradle-config.json'));
return JSON.parse(fs.readFileSync(path.join(this.root, 'cdv-gradle-config.json'), 'utf-8') || '{}');
}
/*
@@ -342,7 +342,7 @@ class ProjectBuilder {
const args = this.getArgs('clean', opts);
return execa(wrapper, args, { stdio: 'inherit', cwd: path.resolve(this.root) })
.then(() => {
fs.removeSync(path.join(this.root, 'out'));
fs.rmSync(path.join(this.root, 'out'), { recursive: true, force: true });
['debug', 'release'].map(config => path.join(this.root, `${config}${SIGNING_PROPERTIES}`))
.forEach(file => {
@@ -350,7 +350,7 @@ class ProjectBuilder {
const hasMarker = hasFile && fs.readFileSync(file, 'utf8')
.includes(MARKER);
if (hasFile && hasMarker) fs.removeSync(file);
if (hasFile && hasMarker) fs.rmSync(file);
});
});
}