mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
chore: clean up unused code
This commit is contained in:
@ -1,11 +1,9 @@
|
|||||||
import { resolve, dirname } from 'path';
|
|
||||||
import Config from 'webpack-chain';
|
import Config from 'webpack-chain';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import get from 'lodash.get';
|
|
||||||
|
|
||||||
import { getProjectFilePath, getProjectRootPath } from '../helpers/project';
|
import { getProjectFilePath } from '../helpers/project';
|
||||||
import { getEntryPath, getPlatformName } from '../helpers/platform';
|
|
||||||
import { env as _env, IWebpackEnv } from '../index';
|
import { env as _env, IWebpackEnv } from '../index';
|
||||||
|
import { getEntryPath } from '../helpers/platform';
|
||||||
import base from './base';
|
import base from './base';
|
||||||
|
|
||||||
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||||
@ -59,37 +57,3 @@ function getAngularCompilerPlugin() {
|
|||||||
const { AngularCompilerPlugin } = require('@ngtools/webpack');
|
const { AngularCompilerPlugin } = require('@ngtools/webpack');
|
||||||
return AngularCompilerPlugin;
|
return AngularCompilerPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: move into project helper if used elsewhere
|
|
||||||
// todo: write tests
|
|
||||||
function findFile(fileName, currentDir): string | null {
|
|
||||||
// console.log(`findFile(${fileName}, ${currentDir})`)
|
|
||||||
const path = resolve(currentDir, fileName);
|
|
||||||
|
|
||||||
if (existsSync(path)) {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
// bail if we reached the root dir
|
|
||||||
if (currentDir === resolve('/')) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// traverse to the parent folder
|
|
||||||
return findFile(fileName, resolve(currentDir, '..'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function findWorkspaceConfig(): string {
|
|
||||||
const possibleConfigNames = ['angular.json', 'workspace.json'];
|
|
||||||
|
|
||||||
for (const name of possibleConfigNames) {
|
|
||||||
const path = findFile(name, getProjectRootPath());
|
|
||||||
|
|
||||||
if (path) {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// not found
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
@ -9,13 +9,13 @@ import TerserPlugin from 'terser-webpack-plugin';
|
|||||||
|
|
||||||
import { getProjectFilePath, getProjectRootPath } from '../helpers/project';
|
import { getProjectFilePath, getProjectRootPath } from '../helpers/project';
|
||||||
import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin';
|
import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin';
|
||||||
|
import { applyFileReplacements } from '../helpers/fileReplacements';
|
||||||
import { addCopyRule, applyCopyRules } from '../helpers/copyRules';
|
import { addCopyRule, applyCopyRules } from '../helpers/copyRules';
|
||||||
import { WatchStatePlugin } from '../plugins/WatchStatePlugin';
|
import { WatchStatePlugin } from '../plugins/WatchStatePlugin';
|
||||||
import { hasDependency } from '../helpers/dependencies';
|
import { hasDependency } from '../helpers/dependencies';
|
||||||
import { applyDotEnvPlugin } from '../helpers/dotEnv';
|
import { applyDotEnvPlugin } from '../helpers/dotEnv';
|
||||||
import { env as _env, IWebpackEnv } from '../index';
|
import { env as _env, IWebpackEnv } from '../index';
|
||||||
import { getIPS } from '../helpers/host';
|
import { getIPS } from '../helpers/host';
|
||||||
import { applyFileReplacements } from '../helpers/fileReplacements';
|
|
||||||
import {
|
import {
|
||||||
getPlatformName,
|
getPlatformName,
|
||||||
getAbsoluteDistPath,
|
getAbsoluteDistPath,
|
||||||
|
@ -19,9 +19,7 @@ interface IPackageJson {
|
|||||||
* Utility function to get the contents of the project package.json
|
* Utility function to get the contents of the project package.json
|
||||||
*/
|
*/
|
||||||
export function getPackageJson() {
|
export function getPackageJson() {
|
||||||
return require(
|
return require(getProjectFilePath('package.json')) as IPackageJson;
|
||||||
getProjectFilePath('package.json')
|
|
||||||
) as IPackageJson;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,3 +29,22 @@ export function getPackageJson() {
|
|||||||
export function getProjectFilePath(filePath: string): string {
|
export function getProjectFilePath(filePath: string): string {
|
||||||
return resolve(getProjectRootPath(), filePath);
|
return resolve(getProjectRootPath(), filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unused helper, but keeping it here as we may need it
|
||||||
|
// todo: remove if unused for next few releases
|
||||||
|
// function findFile(fileName, currentDir): string | null {
|
||||||
|
// // console.log(`findFile(${fileName}, ${currentDir})`)
|
||||||
|
// const path = resolve(currentDir, fileName);
|
||||||
|
//
|
||||||
|
// if (existsSync(path)) {
|
||||||
|
// return path;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // bail if we reached the root dir
|
||||||
|
// if (currentDir === resolve('/')) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // traverse to the parent folder
|
||||||
|
// return findFile(fileName, resolve(currentDir, '..'));
|
||||||
|
// }
|
||||||
|
Reference in New Issue
Block a user