mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-05-20 00:06:24 +08:00
refactor(build): use fs-extra es6 imports
This commit is contained in:
@@ -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]) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user