diff --git a/lib/modules/mergeScripts.es6 b/lib/modules/mergeScripts.es6
index f3413e9..9eab5df 100644
--- a/lib/modules/mergeScripts.es6
+++ b/lib/modules/mergeScripts.es6
@@ -33,7 +33,12 @@ export default function mergeScripts(tree) {
let lastScriptNode = scriptNodes.pop();
scriptNodes.reverse().forEach(scriptNode => {
let scriptContent = (scriptNode.content || []).join(' ');
- lastScriptNode.content.unshift(scriptContent + ' ');
+ scriptContent = scriptContent.trim();
+ if (scriptContent.slice(-1) !== ';') {
+ scriptContent += ';';
+ }
+
+ lastScriptNode.content.unshift(scriptContent);
scriptNode.tag = false;
scriptNode.content = [];
@@ -41,4 +46,4 @@ export default function mergeScripts(tree) {
}
return tree;
-}
\ No newline at end of file
+}
diff --git a/test/modules/mergeScripts.js b/test/modules/mergeScripts.js
index 08783a2..7abeefe 100644
--- a/test/modules/mergeScripts.js
+++ b/test/modules/mergeScripts.js
@@ -15,11 +15,43 @@ describe('mergeScripts', () => {
`,
'\n \n \n \n ' +
- `
-
- `,
+ `
+
+ `,
options
);
});
-});
\ No newline at end of file
+
+ it('should add trailing ; when it\'s missing in oneline ',
+ '',
+ options
+ );
+ });
+
+ it('should add trailing ; when it\'s missing in multiline `,
+ ``,
+ options
+ );
+ });
+});