Skip to content

Commit

Permalink
chore: removed lodash and removed shelljs
Browse files Browse the repository at this point in the history
  • Loading branch information
jortbmd committed Dec 24, 2024
1 parent 3722de0 commit d567de1
Show file tree
Hide file tree
Showing 32 changed files with 354 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"${workspaceFolder}/src/test/workspaces/H753ZI",
"--extensions-dir .vscode-test/extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/integration/customMakefileRulesTest"
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"label": "compile extension",
"type": "shell",
"command": "npm run compile:dev",
"command": "npm run compile",
"options": {},
"group": {
"kind": "build",
Expand Down
2 changes: 1 addition & 1 deletion esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function main() {
minify: production,
sourcemap: !production,
sourcesContent: false,
metafile: !watch,
metafile: analysis,
platform: 'node',
outfile: 'dist/extension.js',
external: ['vscode'],
Expand Down
90 changes: 75 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
"compile": "npm run lint && npm run check-types && node esbuild.js",
"compile:test": "tsc -p ./ ",
"compile:stats": "node esbuild.js --production --stats",
"compile:dev": "webpack --mode development",
"compile:production": "node esbuild.js --production",
"check-types": "tsc --noEmit",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
Expand Down Expand Up @@ -187,6 +189,7 @@
"@types/strip-comments": "^2.0.0",
"@types/unzipper": "^0.10.3",
"@types/vscode": "^1.44",
"@types/which": "^3.0.4",
"@types/xml2js": "^0.4.9",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
Expand All @@ -202,7 +205,7 @@
"mocha": "^10.0.0",
"nyc": "^15.1.0",
"sinon": "^14.0.0",
"swc-loader": "^0.2.3",
"swc-loader": "^0.2.6",
"typedoc": "^0.23.20",
"typescript": "^4.8.4",
"watch": "^0.13.0",
Expand All @@ -219,6 +222,7 @@
"nearest-string": "^1.0.6",
"shelljs": "^0.8.4",
"strip-comments": "^2.0.1",
"which": "^5.0.0",
"xml2js": "^0.6.2",
"yaml": "^2.1.1"
}
Expand Down
1 change: 0 additions & 1 deletion src/@types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
declare module 'shelljs'
declare module 'nearest-string'
7 changes: 3 additions & 4 deletions src/CreateMakefile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@

import 'process';

import { isEmpty, isString, uniq } from 'lodash';

import MakeInfo from './types/MakeInfo';
import { fsPathToPosix } from './Helpers';
import { fsPathToPosix, isString, uniq } from './Helpers';
import { makefileName, STM32_ENVIRONMENT_FILE_NAME } from './Definitions';

/**
Expand Down Expand Up @@ -80,8 +79,8 @@ export function createSingleLineStringList(arr: string[], prefix?: string): stri

export function createGCCPathOutput(makeInfo: MakeInfo): string {
if (makeInfo.tools.armToolchainPath && isString(makeInfo.tools.armToolchainPath)) {
if (makeInfo?.tools?.armToolchainPath && !isEmpty(makeInfo.tools.armToolchainPath) && makeInfo.tools.armToolchainPath !== '.') {
return `GCC_PATH="${fsPathToPosix(makeInfo.tools.armToolchainPath)}`;
if (makeInfo?.tools?.armToolchainPath && makeInfo.tools.armToolchainPath !== '' && makeInfo.tools.armToolchainPath !== '.') {
return `GCC_PATH="${fsPathToPosix(makeInfo.tools.armToolchainPath as string)}`;
}
}
return '';
Expand Down
23 changes: 21 additions & 2 deletions src/Helpers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as path from 'path';
import * as shelljs from 'shelljs';

const { platform } = process;

import { Uri, workspace, env } from 'vscode';

import { TextEncoder } from 'util';
import which = require('which');

export function splitStringLines(input: string): string[] {
return input.split(/\r\n|\r|\n/);
Expand All @@ -22,8 +23,13 @@ export function fsPathToPosix(fsPath: string, escapeSpaces?: boolean): string {
return posixPath;
}

export function whichSync(path: string | undefined | boolean): string | false {
if(!path || typeof path === 'boolean') {return false;}
return which.sync(path, {nothrow: true}) || false;
}

export function convertToolPathToAbsolutePath(toolPath: string, dir?: boolean): string {
const absolutePAth = shelljs.which(toolPath);
const absolutePAth = which.sync(toolPath);
let returnPath = absolutePAth;
returnPath = fsPathToPosix(returnPath);
if (dir) {
Expand Down Expand Up @@ -88,3 +94,16 @@ export function getAutomationShell(): string {
}
return automationShell;
}

export function isString(value: string | boolean | unknown): boolean {
if (typeof value === 'boolean') {
return false;
}
return typeof value === 'string' ||
(!Array.isArray(value) && (value !== null && typeof value === 'object'));
}

export function uniq<T>(arr: T[]): T[] {
const set = new Set(arr);
return [...set];
}
15 changes: 0 additions & 15 deletions src/OpenOcdTargetFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* SOFTWARE.
*/

import { trimEnd } from 'lodash';

const configFiles = [
"stm32c0x.cfg",
Expand Down Expand Up @@ -63,20 +62,6 @@ const configFiles = [
"stm8s105.cfg",
];

export default function getTargetConfig(target: string): string | boolean {
const cleanTarget =
trimEnd(
trimEnd(target, 'cfg'),
'x',
).toLowerCase();
const ind =
configFiles.findIndex((entry: string) => (entry.indexOf(cleanTarget) >= 0));
if (ind >= 0) {
return configFiles[ind];
}
return false;
}

/**
* Finds the openocd target MCU from the full name
* @param name the fullname e.g. STM32H723ZGTx
Expand Down
Loading

0 comments on commit d567de1

Please sign in to comment.