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,4 +1,4 @@
|
||||
import * as fs from 'fs-extra';
|
||||
import { readJSONSync, writeFileSync } from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import * as uglifyJsPlugin from 'uglifyjs-webpack-plugin';
|
||||
import * as unminifiedPlugin from 'unminified-webpack-plugin';
|
||||
@@ -10,7 +10,7 @@ import { Logger } from '../logger';
|
||||
|
||||
const DIST = path.resolve(ROOT, 'dist');
|
||||
const INDEX_PATH = path.resolve(DIST, 'index.js');
|
||||
const INJECTABLE_CLASSES = fs.readJSONSync(EMIT_PATH).map((item: InjectableClassEntry) => {
|
||||
const INJECTABLE_CLASSES = readJSONSync(EMIT_PATH).map((item: InjectableClassEntry) => {
|
||||
item.file =
|
||||
'./' +
|
||||
item.file
|
||||
@@ -71,7 +71,7 @@ function createIndexFile() {
|
||||
fileContent += `require('./@awesome-cordova-plugins/core/bootstrap').checkReady();\n`;
|
||||
fileContent += `require('./@awesome-cordova-plugins/core/ng1').initAngular1(window.IonicNative);`;
|
||||
|
||||
fs.writeFileSync(INDEX_PATH, fileContent, { encoding: 'utf-8' });
|
||||
writeFileSync(INDEX_PATH, fileContent, { encoding: 'utf-8' });
|
||||
}
|
||||
|
||||
function compile() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as fs from 'fs-extra';
|
||||
import { readFileSync, readJSONSync, writeFileSync } from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
|
||||
import { PLUGIN_PATHS, ROOT } from '../build/helpers';
|
||||
@@ -11,13 +11,13 @@ transpile();
|
||||
const outDirs = PLUGIN_PATHS.map(p =>
|
||||
p.replace(path.join(ROOT, 'src'), path.join(ROOT, 'dist')).replace(/[\\/]index.ts/, '')
|
||||
);
|
||||
const injectableClasses = fs.readJSONSync(EMIT_PATH);
|
||||
const injectableClasses = readJSONSync(EMIT_PATH);
|
||||
|
||||
outDirs.forEach(dir => {
|
||||
const classes = injectableClasses.filter(entry => entry.dirName === dir.split(/[\\/]+/).pop());
|
||||
|
||||
let jsFile: string = fs.readFileSync(path.join(dir, 'index.js'), 'utf-8'),
|
||||
dtsFile: string = fs.readFileSync(path.join(dir, 'index.d.ts'), 'utf-8');
|
||||
let jsFile: string = readFileSync(path.join(dir, 'index.js'), 'utf-8'),
|
||||
dtsFile: string = readFileSync(path.join(dir, 'index.d.ts'), 'utf-8');
|
||||
|
||||
classes.forEach(entry => {
|
||||
dtsFile = dtsFile.replace(`class ${entry.className} `, 'class ' + entry.className + 'Original ');
|
||||
@@ -32,6 +32,6 @@ outDirs.forEach(dir => {
|
||||
);
|
||||
});
|
||||
|
||||
fs.writeFileSync(path.join(dir, 'index.js'), jsFile, 'utf-8');
|
||||
fs.writeFileSync(path.join(dir, 'index.d.ts'), dtsFile, 'utf-8');
|
||||
writeFileSync(path.join(dir, 'index.js'), jsFile, 'utf-8');
|
||||
writeFileSync(path.join(dir, 'index.d.ts'), dtsFile, 'utf-8');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as Queue from 'async-promise-queue';
|
||||
import { exec } from 'child_process';
|
||||
import * as fs from 'fs-extra';
|
||||
import { writeJSONSync } from 'fs-extra';
|
||||
import { merge } from 'lodash';
|
||||
import { cpus } from 'os';
|
||||
import * as path from 'path';
|
||||
@@ -49,12 +49,12 @@ function getPackageJsonContent(name: string, peerDependencies = {}, dependencies
|
||||
|
||||
function writePackageJson(data: any, dir: string) {
|
||||
const filePath = path.resolve(dir, 'package.json');
|
||||
fs.writeJSONSync(filePath, data);
|
||||
writeJSONSync(filePath, data);
|
||||
PACKAGES.push(dir);
|
||||
}
|
||||
function writeNGXPackageJson(data: any, dir: string) {
|
||||
const filePath = path.resolve(dir, 'package.json');
|
||||
fs.writeJSONSync(filePath, data);
|
||||
writeJSONSync(filePath, data);
|
||||
}
|
||||
function prepare() {
|
||||
// write @awesome-cordova-plugins/core package.json
|
||||
|
||||
Reference in New Issue
Block a user