Skip to content

Commit

Permalink
Use relative path in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
origami-z committed Feb 2, 2024
1 parent fe3b6f7 commit 2a5c6bb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
24 changes: 19 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import chalk from "chalk";
import glob from "fast-glob";
import { existsSync, readFileSync, writeFileSync } from "fs";
import { dirname, join } from "path";
import { dirname, join, relative } from "path";
import process from "process";
import resolvePackagePath from "resolve-package-path";
import { gt, lte, parse } from "semver";
Expand Down Expand Up @@ -96,7 +96,8 @@ if (mode === undefined || mode === "ts") {
console.log(
chalk.dim(
"Initialising TypeScript project from source glob:",
tsSourceGlob
tsSourceGlob,
". (Use --tsSourceGlob flag to customize)"
)
);
// Very bad way of handling monorepo, adding all ts files from `tsSourceGlob` args, by default is all ts* in packages folder
Expand Down Expand Up @@ -195,7 +196,10 @@ if (mode === undefined || mode === "css") {

const saltThemeCssPath = join(dirname(saltDsThemePkgJsonPath), "index.css");

verboseOnlyDimLog("Reading Salt theme CSS variables from", saltThemeCssPath);
verboseOnlyDimLog(
"Reading Salt theme CSS variables from",
relative(process.cwd(), saltThemeCssPath)
);
const saltThemeCssContent = readFileSync(saltThemeCssPath, {
encoding: "utf8",
flag: "r",
Expand All @@ -208,8 +212,18 @@ if (mode === undefined || mode === "css") {
allSaltThemeCssVars.size
);

const filePaths = glob.sync("*/**/*.@(css|ts|tsx)", {
ignore: ["node_modules", "dist", "build"],
const cssGlob = "*/**/*.@(css|ts|tsx)";
const cssIgnoreFolders = ["node_modules", "dist", "build"];
console.log(
chalk.dim(
"Scanning CSS using source glob:",
cssGlob,
", ignoring folders:",
cssIgnoreFolders
)
);
const filePaths = glob.sync(cssGlob, {
ignore: cssIgnoreFolders,
});

verboseOnlyDimLog("Total files to modify CSS variables", filePaths.length);
Expand Down
7 changes: 6 additions & 1 deletion migration/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SyntaxKind, Node } from "ts-morph";
import { verboseOnlyDimLog, verboseOnlyLog } from "../utils/log.js";
import process from "process";
import { relative } from "path";

/**
* @typedef {Object} RenameImportModuleSpecifierOption
Expand Down Expand Up @@ -245,7 +247,10 @@ export function warnRemovedReactAttribute(
`Error: removed prop \`${attributeText}\` of`,
elementName,
"component detected at",
`${file.getFilePath()}:${attribute.getStartLineNumber()}`
`${relative(
process.cwd(),
file.getFilePath()
)}:${attribute.getStartLineNumber()}`
);
}
}
Expand Down

0 comments on commit 2a5c6bb

Please sign in to comment.