-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from egorAva/feature/cli-options
feat: added the ability to add cli options
- Loading branch information
Showing
9 changed files
with
223 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
cliOptions: { | ||
allowEmptyInput: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const getCliOptions = require("../getCliOptions"); | ||
const path = require("path"); | ||
|
||
describe("getCliOptions", () => { | ||
it("check cli options in jest-runner-stylelint.config", () => { | ||
const rootDir = path.resolve(__dirname, "../../__fixtures__"); | ||
const config = getCliOptions({ rootDir }); | ||
|
||
expect(config).toEqual({ cliOptions: { allowEmptyInput: true } }); | ||
}); | ||
|
||
it("check cli options without config", () => { | ||
const rootDir = path.resolve(__dirname, "./"); | ||
const config = getCliOptions({ rootDir }); | ||
|
||
expect(config).toEqual({ cliOptions: {} }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const normalizeConfig = require("../normalizeConfig"); | ||
|
||
describe("normalizeConfig", () => { | ||
it("check cliOptions", () => { | ||
const config = normalizeConfig({ cliOptions: { arg: "test arg" } }); | ||
expect(config).toEqual({ cliOptions: { arg: "test arg" } }); | ||
}); | ||
|
||
it("check default cliOptions", () => { | ||
const config = normalizeConfig({}); | ||
|
||
expect(config).toEqual({ cliOptions: {} }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { cosmiconfigSync } = require("cosmiconfig"); | ||
const normalizeConfig = require("./normalizeConfig"); | ||
|
||
const explorerSync = cosmiconfigSync("jest-runner-stylelint"); | ||
|
||
const getCliOptions = ({ rootDir }) => { | ||
const result = explorerSync.search(rootDir); | ||
const config = result === null ? {} : result.config; | ||
|
||
return normalizeConfig(config); | ||
}; | ||
|
||
module.exports = getCliOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const normalizeConfig = config => { | ||
return Object.assign({}, config, { | ||
cliOptions: config.cliOptions || {} | ||
}); | ||
}; | ||
|
||
module.exports = normalizeConfig; |