Skip to content

Commit

Permalink
Fix #76 Raise error if RUN has flags but no arguments
Browse files Browse the repository at this point in the history
Signed-off-by: Remy Suen <remy.suen@gmail.com>
  • Loading branch information
rcjsuen committed Apr 2, 2020
1 parent 4edfc57 commit b6880b1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [Unreleased]
### Added
- RUN instructions with only flags and no arguments will now be raised as an error

## [0.0.15] - 2020-03-08
### Fixed
- multiline instructions with empty newlines will no longer throw an error during validation ([#71](https://github.com/rcjsuen/dockerfile-utils/issues/71))
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"main": "./lib/main.js",
"types": "./lib/main.d.ts",
"dependencies": {
"dockerfile-ast": "0.0.24",
"dockerfile-ast": "0.0.25",
"vscode-languageserver-types": "3.6.0"
},
"devDependencies": {
Expand Down
16 changes: 12 additions & 4 deletions test/dockerValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3813,6 +3813,18 @@ describe("Docker Validator Tests", function() {
diagnostics = validateDockerfile("FROM busybox\r\nRUN ls && \\\r\n \t# comment");
assert.equal(diagnostics.length, 0);
});

it("flags only with no argument", function () {
let diagnostics = validateDockerfile("FROM alpine\nRUN --x=y");
assert.equal(diagnostics.length, 1);
assertInstructionMissingArgument(diagnostics[0], 1, 0, 1, 3);

diagnostics = validateDockerfile("FROM alpine\nRUN --x=y --abc=def");
assert.equal(diagnostics.length, 1);
assertInstructionMissingArgument(diagnostics[0], 1, 0, 1, 3);
});

createSingleQuotedJSONTests("RUN");
});

describe("SHELL", function() {
Expand Down Expand Up @@ -4069,10 +4081,6 @@ describe("Docker Validator Tests", function() {
});
});

describe("RUN", function() {
createSingleQuotedJSONTests("RUN");
});

describe("USER", function() {
it("ok", function() {
return testValidArgument("USER", "daemon");
Expand Down

0 comments on commit b6880b1

Please sign in to comment.