Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/checks/phplint.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ module.exports = (options, webRoot) => {
commandArray.push(`--exclude=${exclude}`);
});

commandArray.push(
`--extensions=${
options.extensions
? options.extensions
: "php,module,theme,engine,inc,install"
}`
);
const extensionsStr = options.extensions
? options.extensions
: "php,module,theme,engine,inc,install";
extensionsStr.split(",").forEach((extension) => {
commandArray.push(`--extensions=${extension}`);
});

if (options.verbose) {
commandArray.push("-v");
}
Expand Down
83 changes: 55 additions & 28 deletions src/checks/phplint.test.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,64 @@
const phplint = require('./phplint');
const phplint = require("./phplint");

test('it returns defaults', () => {
expect(phplint({}, 'web')).toEqual(['phplint', '--exclude=vendor', '--exclude=web/core', '--exclude=web/modules/contrib', '--extensions=php,module,theme,engine,inc,install']);
test("it returns defaults", () => {
expect(phplint({}, "web")).toEqual([
"phplint",
"--exclude=vendor",
"--exclude=web/core",
"--exclude=web/modules/contrib",
"--extensions=php",
"--extensions=module",
"--extensions=theme",
"--extensions=engine",
"--extensions=inc",
"--extensions=install",
]);
});

test('it returns no options', () => {
expect(phplint({ no_default_options: true }, 'web')).toEqual(['phplint']);
expect(phplint({
no_default_options: true,
exclude: 'vendor',
}, 'web')).toEqual(['phplint']);
test("it returns no options", () => {
expect(phplint({ no_default_options: true }, "web")).toEqual(["phplint"]);
expect(
phplint(
{
no_default_options: true,
exclude: "vendor",
},
"web"
)
).toEqual(["phplint"]);
});

test('it handles partial inputs', () => {
test("it handles partial inputs", () => {
let command;
command = phplint({
exclude: 'vendor,web/themes/contrib',
}, 'web');
expect(command).toContain('--exclude=vendor');
expect(command).toContain('--exclude=web/themes/contrib');
expect(command).not.toContain('--exclude=web/modules/contrib');
command = phplint(
{
exclude: "vendor,web/themes/contrib",
},
"web"
);
expect(command).toContain("--exclude=vendor");
expect(command).toContain("--exclude=web/themes/contrib");
expect(command).not.toContain("--exclude=web/modules/contrib");

command = phplint({
extensions: 'php,inc',
}, 'docroot');
expect(command).toContain('--extensions=php,inc');
expect(command).toContain('--exclude=docroot/modules/contrib');
command = phplint(
{
extensions: "php,inc",
},
"docroot"
);
expect(command).toContain("--extensions=php");
expect(command).toContain("--extensions=inc");
expect(command).not.toContain("--extensions=module");
expect(command).toContain("--exclude=docroot/modules/contrib");

command = phplint({
verbose: true,
path: 'web/modules/custom',
}, 'docroot');
expect(command).toContain('-v');
expect(command).toContain('--exclude=docroot/modules/contrib');
expect(command).toContain('web/modules/custom');
command = phplint(
{
verbose: true,
path: "web/modules/custom",
},
"docroot"
);
expect(command).toContain("-v");
expect(command).toContain("--exclude=docroot/modules/contrib");
expect(command).toContain("web/modules/custom");
});