refactor(build): use fs-extra es6 imports

This commit is contained in:
Daniel Sogl
2021-09-27 20:26:16 +02:00
parent 87b7de20ff
commit 770052347e
7 changed files with 29 additions and 29 deletions
+5 -4
View File
@@ -1,7 +1,8 @@
import * as ts from 'typescript';
import * as fs from 'fs-extra';
import * as path from 'path';
import { readdirSync } from 'fs-extra';
import { camelCase, clone } from 'lodash';
import * as path from 'path';
import * as ts from 'typescript';
import { Logger } from '../logger';
export const ROOT = path.resolve(__dirname, '../../');
@@ -9,7 +10,7 @@ export const ROOT = path.resolve(__dirname, '../../');
export const TS_CONFIG = clone(require(path.resolve(ROOT, 'tsconfig.json')));
export const COMPILER_OPTIONS = TS_CONFIG.compilerOptions;
export const PLUGINS_ROOT = path.join(ROOT, 'src/@awesome-cordova-plugins/plugins/');
export const PLUGIN_PATHS = fs.readdirSync(PLUGINS_ROOT).map(d => path.join(PLUGINS_ROOT, d, 'index.ts'));
export const PLUGIN_PATHS = readdirSync(PLUGINS_ROOT).map(d => path.join(PLUGINS_ROOT, d, 'index.ts'));
export function getDecorator(node: ts.Node, index = 0): ts.Decorator {
if (node.decorators && node.decorators[index]) {
+5 -6
View File
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as fs from 'fs-extra';
import { copyFileSync, mkdirpSync, readJSONSync, writeJSONSync } from 'fs-extra';
import * as path from 'path';
import * as rimraf from 'rimraf';
import * as rollup from 'rollup';
@@ -82,11 +82,10 @@ export function generateLegacyBundles() {
// remove reference to @awesome-cordova-plugins/core decorators
export function modifyMetadata() {
debugger;
PLUGIN_PATHS.map(p =>
p.replace(path.join(ROOT, 'src'), path.join(ROOT, 'dist')).replace('index.ts', 'ngx/index.metadata.json')
).forEach(p => {
const content = fs.readJSONSync(p);
const content = readJSONSync(p);
let _prop: { members: { [x: string]: any[] } };
for (const prop in content[0].metadata) {
_prop = content[0].metadata[prop];
@@ -99,7 +98,7 @@ export function modifyMetadata() {
}
}
fs.writeJSONSync(p, content);
writeJSONSync(p, content);
});
}
@@ -120,8 +119,8 @@ function createSourceFiles(): string[] {
// delete directory
rimraf.sync(ngxPath);
fs.mkdirpSync(ngxPath);
fs.copyFileSync(indexPath, newPath);
mkdirpSync(ngxPath);
copyFileSync(indexPath, newPath);
return newPath;
});
@@ -1,4 +1,4 @@
import * as fs from 'fs-extra';
import { unlinkSync, writeJSONSync } from 'fs-extra';
import * as path from 'path';
import * as ts from 'typescript';
@@ -51,9 +51,9 @@ export function extractInjectables() {
}
export function emitInjectableClasses() {
fs.writeJSONSync(EMIT_PATH, injectableClasses);
writeJSONSync(EMIT_PATH, injectableClasses);
}
export function cleanEmittedData() {
fs.unlinkSync(EMIT_PATH);
unlinkSync(EMIT_PATH);
}