From 4972389df47cd2f62696085683263ae1b11fc04c Mon Sep 17 00:00:00 2001 From: "Anantachai Saothong (Manta)" Date: Sat, 20 Jan 2018 21:54:31 +0700 Subject: [PATCH] Fixed conditional import See https://github.com/ThisIsManta/stylus-supremacy/issues/20 --- edge/format.js | 8 +++++--- spec/condition/input.styl | 4 +++- spec/condition/output.styl | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/edge/format.js b/edge/format.js index a191823..bea7557 100644 --- a/edge/format.js +++ b/edge/format.js @@ -102,10 +102,12 @@ function format(content, options = {}) { outputBuffer.append(' ') outputBuffer.append(travel(inputNode, inputNode.path, indentLevel, true)) - if (options.insertSemicolons) { - outputBuffer.append(';') + if (insideExpression === false) { + if (options.insertSemicolons) { + outputBuffer.append(';') + } + outputBuffer.append(options.newLineChar) } - outputBuffer.append(options.newLineChar) } else if (inputNode instanceof Stylus.nodes.Group) { // Insert single-line comment(s) diff --git a/spec/condition/input.styl b/spec/condition/input.styl index 80e0167..22d6e84 100644 --- a/spec/condition/input.styl +++ b/spec/condition/input.styl @@ -15,4 +15,6 @@ body negative(n) error('invalid number') unless n is a 'unit' return yes if n < 0 - no \ No newline at end of file + no + +@import -fn if (exists(-fn)); \ No newline at end of file diff --git a/spec/condition/output.styl b/spec/condition/output.styl index 6943a43..bf41fa5 100644 --- a/spec/condition/output.styl +++ b/spec/condition/output.styl @@ -22,4 +22,6 @@ negative(n) { return yes if (n < 0); no; -} \ No newline at end of file +} + +@import -fn if (exists(-fn)); \ No newline at end of file