Skip to content

Commit

Permalink
Add debug for Windows QA
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmorand-sonarsource committed Sep 19, 2024
1 parent d938a5e commit 0526a3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 7 additions & 2 deletions packages/jsts/src/rules/S4328/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Rule } from 'eslint';
import * as estree from 'estree';
import builtins from 'builtin-modules';
import * as ts from 'typescript';
import { generateMeta, getDependenciesFromPackageJson } from '../helpers';
import { generateMeta, getDependenciesFromPackageJson, toUnixPath } from '../helpers';
import { FromSchema } from 'json-schema-to-ts';
import { meta, schema } from './meta';
import { Minimatch } from 'minimatch';
Expand All @@ -38,7 +38,12 @@ export const rule: Rule.RuleModule = {
meta: generateMeta(meta as Rule.RuleMetaData, { messages, schema }),
create(context: Rule.RuleContext) {
// we need to find all the npm manifests from the directory of the analyzed file to the context working directory
const manifests = getManifests(context.filename, context.cwd, fs);
const cwd = toUnixPath(context.cwd);
const fileName = toUnixPath(context.filename);
const manifests = getManifests(fileName, cwd, fs);

console.log('S4328, manifests', manifests);

const dependencies: Set<string> = new Set();

manifests.forEach(manifest => {
Expand Down
9 changes: 5 additions & 4 deletions packages/jsts/src/rules/helpers/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,16 @@ export const getManifests = (
const entries = fileSystem.readdirSync(path);

for (const entry of entries) {
const entryPath = Path.resolve(path, entry);
const entryUnixPath = toUnixPath(entry);
const absoluteEntryPath = Path.join(path, entryUnixPath);

if (Path.basename(entryPath) === 'package.json') {
const content = fileSystem.readFileSync(entryPath);
if (Path.basename(absoluteEntryPath) === 'package.json') {
const content = fileSystem.readFileSync(absoluteEntryPath);

try {
results.push(JSON.parse(content.toString()));
} catch (error) {
console.debug(`Error parsing file ${entryPath}: ${error}`);
console.debug(`Error parsing file ${absoluteEntryPath}: ${error}`);
}
}
}
Expand Down

0 comments on commit 0526a3e

Please sign in to comment.