Skip to content

Commit 377021e

Browse files
authored
Merge pull request #16 from hussainweb/phplint-fix
pass extensions one at a time to phplint
2 parents f45c198 + b758b3e commit 377021e

File tree

4 files changed

+70
-43
lines changed

4 files changed

+70
-43
lines changed

dist/index.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/checks/phplint.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ module.exports = (options, webRoot) => {
1111
commandArray.push(`--exclude=${exclude}`);
1212
});
1313

14-
commandArray.push(
15-
`--extensions=${
16-
options.extensions
17-
? options.extensions
18-
: "php,module,theme,engine,inc,install"
19-
}`
20-
);
14+
const extensionsStr = options.extensions
15+
? options.extensions
16+
: "php,module,theme,engine,inc,install";
17+
extensionsStr.split(",").forEach((extension) => {
18+
commandArray.push(`--extensions=${extension}`);
19+
});
20+
2121
if (options.verbose) {
2222
commandArray.push("-v");
2323
}

src/checks/phplint.test.js

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,64 @@
1-
const phplint = require('./phplint');
1+
const phplint = require("./phplint");
22

3-
test('it returns defaults', () => {
4-
expect(phplint({}, 'web')).toEqual(['phplint', '--exclude=vendor', '--exclude=web/core', '--exclude=web/modules/contrib', '--extensions=php,module,theme,engine,inc,install']);
3+
test("it returns defaults", () => {
4+
expect(phplint({}, "web")).toEqual([
5+
"phplint",
6+
"--exclude=vendor",
7+
"--exclude=web/core",
8+
"--exclude=web/modules/contrib",
9+
"--extensions=php",
10+
"--extensions=module",
11+
"--extensions=theme",
12+
"--extensions=engine",
13+
"--extensions=inc",
14+
"--extensions=install",
15+
]);
516
});
617

7-
test('it returns no options', () => {
8-
expect(phplint({ no_default_options: true }, 'web')).toEqual(['phplint']);
9-
expect(phplint({
10-
no_default_options: true,
11-
exclude: 'vendor',
12-
}, 'web')).toEqual(['phplint']);
18+
test("it returns no options", () => {
19+
expect(phplint({ no_default_options: true }, "web")).toEqual(["phplint"]);
20+
expect(
21+
phplint(
22+
{
23+
no_default_options: true,
24+
exclude: "vendor",
25+
},
26+
"web"
27+
)
28+
).toEqual(["phplint"]);
1329
});
1430

15-
test('it handles partial inputs', () => {
31+
test("it handles partial inputs", () => {
1632
let command;
17-
command = phplint({
18-
exclude: 'vendor,web/themes/contrib',
19-
}, 'web');
20-
expect(command).toContain('--exclude=vendor');
21-
expect(command).toContain('--exclude=web/themes/contrib');
22-
expect(command).not.toContain('--exclude=web/modules/contrib');
33+
command = phplint(
34+
{
35+
exclude: "vendor,web/themes/contrib",
36+
},
37+
"web"
38+
);
39+
expect(command).toContain("--exclude=vendor");
40+
expect(command).toContain("--exclude=web/themes/contrib");
41+
expect(command).not.toContain("--exclude=web/modules/contrib");
2342

24-
command = phplint({
25-
extensions: 'php,inc',
26-
}, 'docroot');
27-
expect(command).toContain('--extensions=php,inc');
28-
expect(command).toContain('--exclude=docroot/modules/contrib');
43+
command = phplint(
44+
{
45+
extensions: "php,inc",
46+
},
47+
"docroot"
48+
);
49+
expect(command).toContain("--extensions=php");
50+
expect(command).toContain("--extensions=inc");
51+
expect(command).not.toContain("--extensions=module");
52+
expect(command).toContain("--exclude=docroot/modules/contrib");
2953

30-
command = phplint({
31-
verbose: true,
32-
path: 'web/modules/custom',
33-
}, 'docroot');
34-
expect(command).toContain('-v');
35-
expect(command).toContain('--exclude=docroot/modules/contrib');
36-
expect(command).toContain('web/modules/custom');
54+
command = phplint(
55+
{
56+
verbose: true,
57+
path: "web/modules/custom",
58+
},
59+
"docroot"
60+
);
61+
expect(command).toContain("-v");
62+
expect(command).toContain("--exclude=docroot/modules/contrib");
63+
expect(command).toContain("web/modules/custom");
3764
});

0 commit comments

Comments
 (0)