Skip to content

Commit 5504113

Browse files
author
Chuck Meyer
authored
Merge pull request #17 from kddejong/Fix/ValidateCfnOnEverySave
Validate if the file is a CFN on every save
2 parents 5994b94 + cb18a95 commit 5504113

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

server/src/server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,10 @@ function validateCloudFormationFile(document: TextDocument): void {
108108
let uri = document.uri;
109109

110110
if (isValidating[uri]) {
111+
connection.console.log("Already validating template: " + uri.toString());
111112
return;
112113
}
113114

114-
isValidating[uri] = true;
115-
116115
let file_to_lint = Files.uriToFilePath(uri);
117116

118117
let is_cfn_regex = new RegExp('"?AWSTemplateFormatVersion"?\s*');
@@ -124,31 +123,32 @@ function validateCloudFormationFile(document: TextDocument): void {
124123
}
125124
}
126125

127-
connection.console.log("Is CFN: " + is_cfn);
126+
connection.console.log("File '" + uri.toString() + " is a CFN? " + is_cfn);
128127

129128
if (is_cfn) {
130129
let args = ['--format', 'json', '--template', file_to_lint];
131130

132131
if (IgnoreRules.length > 0) {
133132
for (var ignoreRule of IgnoreRules) {
134-
args.push('--ignore-checks')
135-
args.push(ignoreRule)
133+
args.push('--ignore-checks');
134+
args.push(ignoreRule);
136135
}
137136
}
138137

139138
if (AppendRules.length > 0) {
140139
for (var appendRule of AppendRules) {
141-
args.push('--append-rules')
142-
args.push(appendRule)
140+
args.push('--append-rules');
141+
args.push(appendRule);
143142
}
144143
}
145144

146145
if (OverrideSpecPath !== "") {
147-
args.push('--override-spec', OverrideSpecPath)
146+
args.push('--override-spec', OverrideSpecPath);
148147
}
149148

150149
connection.console.log(`running............. ${Path} ${args}`);
151150

151+
isValidating[uri] = true;
152152
let child = spawn(
153153
Path,
154154
args

0 commit comments

Comments
 (0)