Skip to content

Commit

Permalink
build(stylelint): Fix stylelint on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Holzer committed Sep 9, 2020
1 parent 0917825 commit 3a82ac6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
16 changes: 16 additions & 0 deletions patches/stylelint+13.2.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/node_modules/stylelint/lib/standalone.js b/node_modules/stylelint/lib/standalone.js
index 630af7e..dbf55e7 100644
--- a/node_modules/stylelint/lib/standalone.js
+++ b/node_modules/stylelint/lib/standalone.js
@@ -198,9 +198,9 @@ module.exports = function(options) {
fileCache = new FileCache(cacheLocation);
// Remove cache file if cache option is disabled
fileCache.destroy();
- }
+ }

- return globby(fileList, globbyOptions)
+ return Promise.resolve(fileList)
.then((filePaths) => {
// The ignorer filter needs to check paths relative to cwd
filePaths = filterFilePaths(
7 changes: 2 additions & 5 deletions tools/bazel_rules/stylelint/junit-formatter/parse-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
*/

import { LintResult, Warning } from 'stylelint';
import { relative, join } from 'path';
import { relative } from 'path';
import { ParsedSuite, ParsedCase } from './parsed-suite.interface';

// bazel run files helper used to resolve paths that are created with `$(location ...)`
const { dir, workspace } = require(`${process.env.BAZEL_NODE_RUNFILES_HELPER}`);

/** Creates an object that can be used to create an XML out of the provided lint result */
export function parseSuite(testSuite: LintResult): ParsedSuite {
const name = relative(join(dir, workspace), testSuite.source);
const name = relative(process.cwd(), testSuite.source);
const failuresCount = testSuite.warnings.length;
const testCases = testSuite.errored
? testSuite.warnings.map((testCase: Warning) =>
Expand Down
14 changes: 7 additions & 7 deletions tools/bazel_rules/stylelint/run-stylelint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
import { lint, LinterResult } from 'stylelint';
import { junitFormatter, createXML } from './junit-formatter';
import { writeFileSync } from 'fs';
import { normalize } from 'path';
import { options } from 'yargs';

const { BAZEL_NODE_RUNFILES_HELPER, XML_OUTPUT_FILE } = process.env;
const { XML_OUTPUT_FILE } = process.env;

if (!BAZEL_NODE_RUNFILES_HELPER || !XML_OUTPUT_FILE) {
if (!XML_OUTPUT_FILE) {
throw new Error('Bazel environment variables are not set!');
}

// bazel run files helper used to resolve paths that are created with `$(location ...)`
const runFilesHelper = require(BAZEL_NODE_RUNFILES_HELPER);

const { files, allowEmpty, config } = options({
files: { type: 'array', default: [] },
config: { type: 'string', demandOption: true },
Expand All @@ -44,8 +42,10 @@ async function main(): Promise<void> {
};
} else {
lintingOutcome = await lint({
configFile: runFilesHelper.resolve(config),
files: files.map((f) => runFilesHelper.resolve(f)),
configFile: normalize(config),
configBasedir: process.cwd(),
files: files,
disableDefaultIgnores: true,
formatter: junitFormatter,
});
}
Expand Down
4 changes: 2 additions & 2 deletions tools/bazel_rules/stylelint/stylelint_macro.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def stylelint_macro(
**kwargs: remaining args to pass to the stylelint_test rule
"""

args = ["--files=\"$(location %s)\"" % s for s in srcs]
args = ["--files=\"$(rootpath %s)\"" % s for s in srcs]

if config:
srcs.append(config)
else:
config = "//:.stylelintrc"

# append the config file
args.append("--config $(location %s)" % config)
args.append("--config $(rootpath %s)" % config)

# # If no tests are matching the glob the process wont exit if set
if allow_empty_input:
Expand Down

0 comments on commit 3a82ac6

Please sign in to comment.