cleanup(core): remove unneccessary dependencies and refactored prettier path resolve (#5852)

removed depenedencies app-root-path and resolve
refactored workspace/src/command-line/format.ts to
use require.resolve
This commit is contained in:
Phillip Barta 2021-06-02 03:49:15 +02:00 committed by GitHub
parent 329bb25404
commit 7c34f779e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 17 deletions

View File

@ -109,7 +109,6 @@
"@typescript-eslint/experimental-utils": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
"angular": "1.8.0",
"app-root-path": "^2.0.1",
"autoprefixer": "^10.2.5",
"babel-jest": "26.2.2",
"caniuse-lite": "^1.0.30001030",

View File

@ -76,7 +76,6 @@
"flat": "^5.0.2",
"minimatch": "3.0.4",
"enquirer": "~2.3.6",
"resolve": "1.17.0",
"tslib": "^2.0.0"
}
}

View File

@ -1,6 +1,5 @@
import { execSync } from 'child_process';
import * as path from 'path';
import * as resolve from 'resolve';
import { getProjectRoots, parseFiles } from './shared';
import { fileExists } from '../utilities/fileutils';
import {
@ -39,6 +38,8 @@ const PRETTIER_EXTENSIONS = [
const MATCH_ALL_PATTERN = `**/*.{${PRETTIER_EXTENSIONS.join(',')}}`;
const PRETTIER_PATH = require.resolve('prettier/bin-prettier');
export function format(command: 'check' | 'write', args: yargs.Arguments) {
const { nxArgs } = splitArgsIntoNxArgsAndOverrides(args, 'affected');
@ -109,7 +110,7 @@ function chunkify(target: string[], size: number): string[][] {
function write(patterns: string[]) {
if (patterns.length > 0) {
execSync(`node "${prettierPath()}" --write ${patterns.join(' ')}`, {
execSync(`node "${PRETTIER_PATH}" --write ${patterns.join(' ')}`, {
stdio: [0, 1, 2],
});
}
@ -119,7 +120,7 @@ function check(patterns: string[]) {
if (patterns.length > 0) {
try {
execSync(
`node "${prettierPath()}" --list-different ${patterns.join(' ')}`,
`node "${PRETTIER_PATH}" --list-different ${patterns.join(' ')}`,
{
stdio: [0, 1, 2],
}
@ -130,13 +131,6 @@ function check(patterns: string[]) {
}
}
function prettierPath() {
const basePath = path.dirname(
resolve.sync('prettier', { basedir: __dirname })
);
return path.join(basePath, 'bin-prettier.js');
}
function updateWorkspaceJsonToMatchFormatVersion() {
try {
const workspaceJson = JSON.parse(

View File

@ -6156,11 +6156,6 @@ app-root-dir@^1.0.2:
resolved "https://registry.yarnpkg.com/app-root-dir/-/app-root-dir-1.0.2.tgz#38187ec2dea7577fff033ffcb12172692ff6e118"
integrity sha1-OBh+wt6nV3//Az/8sSFyaS/24Rg=
app-root-path@^2.0.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-2.2.1.tgz#d0df4a682ee408273583d43f6f79e9892624bc9a"
integrity sha512-91IFKeKk7FjfmezPKkwtaRvSpnUc4gDwPAjA1YZ9Gn0q0PPeW+vbeUsZuyDwjI7+QTHhcLen2v25fi/AmhvbJA==
append-field@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/append-field/-/append-field-1.0.0.tgz#1e3440e915f0b1203d23748e78edd7b9b5b43e56"