Skip to content
This repository
Browse code

Rename fileName to filename

  • Loading branch information...
commit e8ef61dbd99d0014e62a440cf2e2e56cb99f6332 1 parent c0cafc5
Glen Huang authored

Showing 28 changed files with 106 additions and 106 deletions. Show diff stats Hide diff stats

  1. +32 32 bin/roole
  2. +1 1  lib/browser.js
  3. +2 2 lib/err.js
  4. +3 3 lib/evaluator/node/arithmetic.js
  5. +1 1  lib/evaluator/node/call.js
  6. +1 1  lib/evaluator/node/classSelector.js
  7. +2 2 lib/evaluator/node/for.js
  8. +1 1  lib/evaluator/node/identifier.js
  9. +1 1  lib/evaluator/node/mediaQueryInterpolation.js
  10. +2 2 lib/evaluator/node/module.js
  11. +1 1  lib/evaluator/node/range.js
  12. +1 1  lib/evaluator/node/return.js
  13. +3 3 lib/evaluator/node/root.js
  14. +1 1  lib/evaluator/node/selectorInterpolation.js
  15. +1 1  lib/evaluator/node/string.js
  16. +1 1  lib/evaluator/node/unary.js
  17. +1 1  lib/evaluator/node/variable.js
  18. +2 2 lib/extender/node/ampersandSelector.js
  19. +3 3 lib/extender/node/root.js
  20. +1 1  lib/extender/node/selector.js
  21. +2 2 lib/formatter.js
  22. +15 15 lib/importer/importer.js
  23. +1 1  lib/normalizer/node/media.js
  24. +3 3 lib/normalizer/node/root.js
  25. +3 3 lib/parser/index.js
  26. +3 3 lib/roole.js
  27. +17 17 test/assert.js
  28. +1 1  test/unit/import.js
64 bin/roole
@@ -67,45 +67,45 @@ function compileStdin(callback) {
67 67 });
68 68 }
69 69
70   -function resolveFiles(filePaths, dirPath) {
  70 +function resolveFiles(filenames, dirname) {
71 71 var files = [];
72   - filePaths.forEach(function(filePath) {
73   - var stat = fs.statSync(filePath);
  72 + filenames.forEach(function(filename) {
  73 + var stat = fs.statSync(filename);
74 74 if (stat.isFile()) {
75 75 var file = {
76   - path: filePath,
77   - content: fs.readFileSync(filePath, 'utf8')
  76 + name: filename,
  77 + content: fs.readFileSync(filename, 'utf8')
78 78 };
79 79
80 80 if (!program.out) {
81   - file.outputPath = file.path;
  81 + file.outputName = file.name;
82 82 } else {
83   - if (!dirPath) {
84   - var base = path.basename(file.path);
85   - file.outputPath = path.join(program.out, base);
  83 + if (!dirname) {
  84 + var base = path.basename(file.name);
  85 + file.outputName = path.join(program.out, base);
86 86 } else {
87   - var subpath = path.relative(dirPath, file.path);
88   - file.outputPath = path.join(program.out, subpath);
  87 + var relpath = path.relative(dirname, file.name);
  88 + file.outputName = path.join(program.out, relpath);
89 89 }
90 90 }
91   - file.outputPath = file.outputPath.replace(/\.roo$|$/, '.css');
  91 + file.outputName = file.outputName.replace(/\.roo$|$/, '.css');
92 92
93 93 files.push(file);
94 94 } else if (stat.isDirectory()) {
95   - var dir = filePath;
96   - var filePaths = fs.readdirSync(dir);
97   - filePaths = filePaths.map(function(filePath) {
98   - return path.join(dir, filePath);
99   - }).filter(function(filePath) {
100   - var stat = fs.statSync(filePath);
  95 + var dir = filename;
  96 + var filenames = fs.readdirSync(dir);
  97 + filenames = filenames.map(function(filename) {
  98 + return path.join(dir, filename);
  99 + }).filter(function(filename) {
  100 + var stat = fs.statSync(filename);
101 101 if (stat.isFile()) {
102   - var hasExt = /\.roo$/.test(filePath);
  102 + var hasExt = /\.roo$/.test(filename);
103 103 return hasExt;
104 104 }
105 105
106 106 return stat.isDirectory();
107 107 });
108   - files = files.concat(resolveFiles(filePaths, dirPath || filePath));
  108 + files = files.concat(resolveFiles(filenames, dirname || filename));
109 109 }
110 110 });
111 111 return files;
@@ -125,7 +125,7 @@ function compileFiles(files, callback) {
125 125 }
126 126
127 127 function compileFile(file, callback) {
128   - options.fileName = file.path;
  128 + options.filename = file.name;
129 129 roole.compile(file.content, options, function(error, css) {
130 130 if (error) {
131 131 throw error;
@@ -146,29 +146,29 @@ function writeFiles(files) {
146 146 function writeFile(file, watching) {
147 147 if (!file.compiledContent && !program.force) {
148 148 if (!program.watch) {
149   - console.log('INFO:', file.path, 'compiles to empty string, not writing to file');
  149 + console.log('INFO:', file.name, 'compiles to empty string, not writing to file');
150 150 } else if (watching) {
151   - console.log(' compiled', file.path, 'to empty string, not writing to file');
  151 + console.log(' compiled', file.name, 'to empty string, not writing to file');
152 152 }
153 153 } else {
154   - var dir = path.dirname(file.outputPath);
  154 + var dir = path.dirname(file.outputName);
155 155 if (!existsSync(dir)) { mkdirp.sync(dir); }
156   - fs.writeFileSync(file.outputPath, file.compiledContent);
  156 + fs.writeFileSync(file.outputName, file.compiledContent);
157 157
158 158 if (program.watch && watching) {
159   - console.log(' compiled', file.path, 'to', file.outputPath);
  159 + console.log(' compiled', file.name, 'to', file.outputName);
160 160 }
161 161 }
162 162 }
163 163
164 164 function watchFiles(files) {
165   - program.args.forEach(function(filePath) {
166   - var stat = fs.statSync(filePath);
167   - if (stat.isDirectory() && filePath.slice(-1) !== '/') {
168   - filePath += '/';
  165 + program.args.forEach(function(filename) {
  166 + var stat = fs.statSync(filename);
  167 + if (stat.isDirectory() && filename.slice(-1) !== '/') {
  168 + filename += '/';
169 169 }
170 170
171   - console.log(' watching', filePath);
  171 + console.log(' watching', filename);
172 172 });
173 173
174 174 files.forEach(function(file) {
@@ -177,7 +177,7 @@ function watchFiles(files) {
177 177 }
178 178
179 179 function watchFile(file) {
180   - fs.watchFile(file.path, {interval: 100}, function(curr, prev) {
  180 + fs.watchFile(file.name, {interval: 100}, function(curr, prev) {
181 181 if (curr.mtime <= prev.mtime) {
182 182 return;
183 183 }
2  lib/browser.js
@@ -33,7 +33,7 @@ Array.prototype.forEach.call(elements, function(element) {
33 33 throw error;
34 34 }
35 35
36   - options.fileName = url;
  36 + options.filename = url;
37 37 roole.compile(content, options, function(error, css) {
38 38 if (error) {
39 39 displayError(error.message);
4 lib/err.js
@@ -6,13 +6,13 @@
6 6 'use strict';
7 7 /* exported Err */
8 8
9   -var Err = module.exports = function(message, node, fileName) {
  9 +var Err = module.exports = function(message, node, filename) {
10 10 var error = new Error(message);
11 11
12 12 error.line = node.loc.line;
13 13 error.column = node.loc.column;
14 14 error.offset = node.loc.offset;
15   - error.fileName = fileName;
  15 + error.filename = filename;
16 16
17 17 return error;
18 18 };
6 lib/evaluator/node/arithmetic.js
@@ -104,7 +104,7 @@ Evaluator.prototype.visitArithmetic = function(arithmeticNode) {
104 104 case 'dimension / percentage':
105 105 var divisor = rightNode.children[0];
106 106 if (!divisor) {
107   - throw Err('divide by zero', rightNode, this.fileName);
  107 + throw Err('divide by zero', rightNode, this.filename);
108 108 }
109 109
110 110 var leftClone = Node.clone(leftNode);
@@ -115,7 +115,7 @@ Evaluator.prototype.visitArithmetic = function(arithmeticNode) {
115 115 case 'number / percentage':
116 116 var divisor = rightNode.children[0];
117 117 if (!divisor) {
118   - throw Err('divide by zero', rightNode, this.fileName);
  118 + throw Err('divide by zero', rightNode, this.filename);
119 119 }
120 120
121 121 var rightClone = Node.clone(rightNode);
@@ -136,5 +136,5 @@ Evaluator.prototype.visitArithmetic = function(arithmeticNode) {
136 136 return leftClone;
137 137 }
138 138
139   - throw Err("unsupported binary operation: '" + leftNode.type + "' " + operator + " '" + rightNode.type + "'", leftNode, this.fileName);
  139 + throw Err("unsupported binary operation: '" + leftNode.type + "' " + operator + " '" + rightNode.type + "'", leftNode, this.filename);
140 140 };
2  lib/evaluator/node/call.js
@@ -14,7 +14,7 @@ Evaluator.prototype.visitCall = function(callNode) {
14 14 }
15 15
16 16 if (functionNode.type !== 'function') {
17   - throw Err("'" + functionNode.type + "' is not a 'function'", functionNode, this.fileName);
  17 + throw Err("'" + functionNode.type + "' is not a 'function'", functionNode, this.filename);
18 18 }
19 19
20 20 this.scope.add();
2  lib/evaluator/node/classSelector.js
@@ -8,7 +8,7 @@ Evaluator.prototype.visitClassSelector = function(classSelectorNode) {
8 8
9 9 var valueNode = classSelectorNode.children[0];
10 10 if (valueNode.type !== 'identifier') {
11   - throw Err("'" + valueNode.type + "' can not be used in class selector", valueNode, this.fileName);
  11 + throw Err("'" + valueNode.type + "' can not be used in class selector", valueNode, this.filename);
12 12 }
13 13 var value = valueNode.children[0];
14 14
4 lib/evaluator/node/for.js
@@ -10,11 +10,11 @@ Evaluator.prototype.visitFor = function(forNode) {
10 10 if (stepNode) {
11 11 stepNumber = Node.toNumber(stepNode);
12 12 if (stepNumber === null) {
13   - throw Err("step number must be a numberic value", stepNode, this.fileName);
  13 + throw Err("step number must be a numberic value", stepNode, this.filename);
14 14 }
15 15
16 16 if (!stepNumber) {
17   - throw Err("step number is not allowed to be zero", stepNode, this.fileName);
  17 + throw Err("step number is not allowed to be zero", stepNode, this.filename);
18 18 }
19 19 }
20 20
2  lib/evaluator/node/identifier.js
@@ -10,7 +10,7 @@ Evaluator.prototype.visitIdentifier = function(identifierNode) {
10 10 var value = childNodes.map(function(childNode) {
11 11 var value = Node.toString(childNode);
12 12 if (value === null) {
13   - throw Err("'" + childNode.type + "' is not allowed to be interpolated in 'identifier'", childNode, this.fileName);
  13 + throw Err("'" + childNode.type + "' is not allowed to be interpolated in 'identifier'", childNode, this.filename);
14 14 }
15 15
16 16 return value;
2  lib/evaluator/node/mediaQueryInterpolation.js
@@ -15,7 +15,7 @@ Evaluator.prototype.visitMediaInterpolation = function(mediaInterpolationNode) {
15 15
16 16 var value = valueNode.children[0].trim();
17 17 var options = {
18   - fileName: this.fileName,
  18 + filename: this.filename,
19 19 startRule: 'mediaQuery',
20 20 loc: valueNode.loc
21 21 };
4 lib/evaluator/node/module.js
@@ -10,13 +10,13 @@ Evaluator.prototype.visitModule = function(moduleNode) {
10 10 var nameNode = this.visit(moduleNode.children[0]);
11 11 var name = Node.toString(nameNode);
12 12 if (name === null) {
13   - throw Err("'" + nameNode.type + "' can not be used as a module name" , nameNode, this.fileName);
  13 + throw Err("'" + nameNode.type + "' can not be used as a module name" , nameNode, this.filename);
14 14 }
15 15
16 16 var separatorNode = this.visit(moduleNode.children[1]);
17 17 var separator = separatorNode ? Node.toString(separatorNode) : '-';
18 18 if (separator === null) {
19   - throw Err("'" + separatorNode.type + "' can not be used as a module name separator" , separatorNode, this.fileName);
  19 + throw Err("'" + separatorNode.type + "' can not be used as a module name separator" , separatorNode, this.filename);
20 20 }
21 21
22 22 this.parentModuleName = parentModuleName + name + separator;
2  lib/evaluator/node/range.js
@@ -18,6 +18,6 @@ Evaluator.prototype.visitRange = function(rangeNode) {
18 18 }
19 19
20 20 if (invalidNode) {
21   - throw Err("only numberic values are allowed in 'range'", invalidNode, this.fileName);
  21 + throw Err("only numberic values are allowed in 'range'", invalidNode, this.filename);
22 22 }
23 23 };
2  lib/evaluator/node/return.js
@@ -5,7 +5,7 @@ var Evaluator = require('../evaluator');
5 5
6 6 Evaluator.prototype.visitReturn = function(returnNode) {
7 7 if (!this.insideFunction) {
8   - throw Err('@return is only allowed inside @function', returnNode, this.fileName);
  8 + throw Err('@return is only allowed inside @function', returnNode, this.filename);
9 9 }
10 10
11 11 if (!this.insideMixin) {
6 lib/evaluator/node/root.js
@@ -3,10 +3,10 @@
3 3 var Evaluator = require('../evaluator');
4 4
5 5 Evaluator.prototype.visitRoot = function(rootNode) {
6   - var fileName = this.fileName;
7   - this.fileName = rootNode.fileName;
  6 + var filename = this.filename;
  7 + this.filename = rootNode.filename;
8 8
9 9 this.visit(rootNode.children);
10 10
11   - this.fileName = fileName;
  11 + this.filename = filename;
12 12 };
2  lib/evaluator/node/selectorInterpolation.js
@@ -14,7 +14,7 @@ Evaluator.prototype.visitSelectorInterpolation = function(selectorInterpolationN
14 14
15 15 var value = valueNode.children[0].trim();
16 16 var options = {
17   - fileName: this.fileName,
  17 + filename: this.filename,
18 18 startRule: 'selector',
19 19 loc: valueNode.loc
20 20 };
2  lib/evaluator/node/string.js
@@ -13,7 +13,7 @@ Evaluator.prototype.visitString = function(stringNode) {
13 13 var value = childNodes.map(function(childNode) {
14 14 var value = Node.toString(childNode);
15 15 if (value === null) {
16   - throw Err("'" + childNode.type + "' is not allowed to be interpolated in 'string'", childNode, this.fileName);
  16 + throw Err("'" + childNode.type + "' is not allowed to be interpolated in 'string'", childNode, this.filename);
17 17 }
18 18
19 19 if (childNode.type === 'string') {
2  lib/evaluator/node/unary.js
@@ -28,5 +28,5 @@ Evaluator.prototype.visitUnary = function(unaryNode) {
28 28 return operandClone;
29 29 }
30 30
31   - throw Err("unsupported unary operation: " + operator + "'" + operandNode.type + "'", unaryNode, this.fileName);
  31 + throw Err("unsupported unary operation: " + operator + "'" + operandNode.type + "'", unaryNode, this.filename);
32 32 };
2  lib/evaluator/node/variable.js
@@ -9,7 +9,7 @@ Evaluator.prototype.visitVariable = function(variableNode) {
9 9 var valueNode = this.scope.resolve(variableName);
10 10
11 11 if (!valueNode) {
12   - throw Err('$' + variableName + ' is undefined', variableNode, this.fileName);
  12 + throw Err('$' + variableName + ' is undefined', variableNode, this.filename);
13 13 }
14 14
15 15 valueNode = Node.clone(valueNode, false);
4 lib/extender/node/ampersandSelector.js
@@ -6,7 +6,7 @@ var Extender = require('../extender');
6 6
7 7 Extender.prototype.visitAmpersandSelector = function(ampersandSelectorNode) {
8 8 if (!this.parentSelector) {
9   - throw Err("& selector is not allowed at the top level", ampersandSelectorNode, this.fileName);
  9 + throw Err("& selector is not allowed at the top level", ampersandSelectorNode, this.filename);
10 10 }
11 11
12 12 this.hasAmpersandSelector = true;
@@ -20,7 +20,7 @@ Extender.prototype.visitAmpersandSelector = function(ampersandSelectorNode) {
20 20 case 'typeSelector':
21 21 break;
22 22 default:
23   - throw Err("parent selector '" + lastNode.type + "' is not allowed to be appended", ampersandSelectorNode, this.fileName);
  23 + throw Err("parent selector '" + lastNode.type + "' is not allowed to be appended", ampersandSelectorNode, this.filename);
24 24 }
25 25
26 26 var lastClone = Node.clone(lastNode);
6 lib/extender/node/root.js
@@ -3,14 +3,14 @@
3 3 var Extender = require('../extender');
4 4
5 5 Extender.prototype.visitRoot = function(rootNode) {
6   - var fileName = this.fileName;
7   - this.fileName = rootNode.fileName;
  6 + var filename = this.filename;
  7 + this.filename = rootNode.filename;
8 8
9 9 var extendBoundaryNode = this.extendBoundaryNode;
10 10 this.extendBoundaryNode = rootNode;
11 11
12 12 this.visit(rootNode.children);
13 13
14   - this.fileName = fileName;
  14 + this.filename = filename;
15 15 this.extendBoundaryNode = extendBoundaryNode;
16 16 };
2  lib/extender/node/selector.js
@@ -16,7 +16,7 @@ Extender.prototype.visitSelector = function(selectorNode) {
16 16 var startWithCombinator = firstNode.type === 'combinator';
17 17 if (startWithCombinator) {
18 18 if (!this.parentSelector) {
19   - throw Err("selector starting with a combinator is not allowed at the top level", firstNode, this.fileName);
  19 + throw Err("selector starting with a combinator is not allowed at the top level", firstNode, this.filename);
20 20 }
21 21
22 22 selectorNode.children = this.parentSelector.children.concat(selectorNode.children);
4 lib/formatter.js
@@ -15,7 +15,7 @@ formatter.format = function(error, input) {
15 15
16 16 var lineNumber = error.line;
17 17 var columnNumber = error.column;
18   - var fileName = error.fileName;
  18 + var filename = error.filename;
19 19 var lines = input.split(/\r\n|[\r\n]/);
20 20 var siblingLineSize = 4;
21 21 var startLineNumber = Math.max(lineNumber - siblingLineSize, 1);
@@ -53,6 +53,6 @@ formatter.format = function(error, input) {
53 53 }, '');
54 54
55 55 return message +
56   - '\n\n ' + '(' + (fileName ? fileName + ' ' : '') + error.line + ':' + error.column + ')' +
  56 + '\n\n ' + '(' + (filename ? filename + ' ' : '') + error.line + ':' + error.column + ')' +
57 57 '\n' + context;
58 58 };
30 lib/importer/importer.js
@@ -46,12 +46,12 @@ Importer.prototype.visitRuleList = Importer.prototype.visitNode;
46 46 Importer.prototype.visitNode = _.noop;
47 47
48 48 Importer.prototype.visitRoot = function(rootNode) {
49   - var fileName = this.fileName;
50   - this.fileName = rootNode.fileName;
  49 + var filename = this.filename;
  50 + this.filename = rootNode.filename;
51 51
52 52 this.visit(rootNode.children);
53 53
54   - this.fileName = fileName;
  54 + this.filename = filename;
55 55 };
56 56
57 57 Importer.prototype.visitImport = function(importNode) {
@@ -65,25 +65,25 @@ Importer.prototype.visitImport = function(importNode) {
65 65 return;
66 66 }
67 67
68   - var fileName = urlNode.children[0];
69   - if (/^\w+:\/\//.test(fileName)) {
  68 + var filename = urlNode.children[0];
  69 + if (/^\w+:\/\//.test(filename)) {
70 70 return;
71 71 }
72 72
73   - if (!/\.[a-z]+$/i.test(fileName)) {
74   - fileName += '.roo';
  73 + if (!/\.[a-z]+$/i.test(filename)) {
  74 + filename += '.roo';
75 75 }
76   - fileName = _.joinPaths(_.dirname(this.fileName), fileName);
  76 + filename = _.joinPaths(_.dirname(this.filename), filename);
77 77
78   - if (this.imported[fileName]) {
  78 + if (this.imported[filename]) {
79 79 return null;
80 80 }
81 81
82   - this.imported[fileName] = true;
  82 + this.imported[filename] = true;
83 83
84   - var content = this.imports[fileName];
  84 + var content = this.imports[filename];
85 85 if (typeof content === 'string') {
86   - var ast = parser.parse(content, {fileName: fileName});
  86 + var ast = parser.parse(content, {filename: filename});
87 87 return this.visit(ast);
88 88 }
89 89
@@ -91,7 +91,7 @@ Importer.prototype.visitImport = function(importNode) {
91 91
92 92 var callback = this.callback;
93 93
94   - loader.load(fileName, function(error, content) {
  94 + loader.load(filename, function(error, content) {
95 95 if (this.hasError) {
96 96 return;
97 97 }
@@ -103,8 +103,8 @@ Importer.prototype.visitImport = function(importNode) {
103 103
104 104 var rootNode;
105 105 try {
106   - this.imports[fileName] = content;
107   - rootNode = parser.parse(content, {fileName: fileName});
  106 + this.imports[filename] = content;
  107 + rootNode = parser.parse(content, {filename: filename});
108 108 this.visit(rootNode);
109 109 } catch (error) {
110 110 this.hasError = true;
2  lib/normalizer/node/media.js
@@ -34,7 +34,7 @@ Normalizer.prototype.visitMedia = function(mediaNode) {
34 34
35 35 if (propertyNodes.length) {
36 36 if (!this.parentSelectorList) {
37   - throw Err("@media containing properties is not allowed at the top level", mediaNode, this.fileName);
  37 + throw Err("@media containing properties is not allowed at the top level", mediaNode, this.filename);
38 38 }
39 39
40 40 var firstPropertyNode = propertyNodes[0];
6 lib/normalizer/node/root.js
@@ -6,13 +6,13 @@ Normalizer.prototype.visitRoot = function(rootNode) {
6 6 var parentRoot = this.parentRoot;
7 7 this.parentRoot = rootNode;
8 8
9   - var fileName = this.fileName;
10   - this.fileName = rootNode.fileName;
  9 + var filename = this.filename;
  10 + this.filename = rootNode.filename;
11 11
12 12 var childNodes = this.visit(rootNode.children);
13 13
14 14 this.parentRoot = parentRoot;
15   - this.fileName = fileName;
  15 + this.filename = filename;
16 16
17 17 if (parentRoot && !childNodes.length) {
18 18 return null;
6 lib/parser/index.js
@@ -4,11 +4,11 @@ var generatedParser = require('./generatedParser');
4 4 var parser = exports;
5 5
6 6 parser.parse = function(input, options) {
7   - var fileName = options.fileName;
  7 + var filename = options.filename;
8 8
9 9 try {
10 10 var ast = generatedParser.parse(input, options);
11   - if (ast.type === 'root') { ast.fileName = fileName; }
  11 + if (ast.type === 'root') { ast.filename = filename; }
12 12
13 13 return ast;
14 14 } catch(error) {
@@ -27,7 +27,7 @@ parser.parse = function(input, options) {
27 27 }
28 28 }
29 29 error.message = "unexpected " + found;
30   - error.fileName = fileName;
  30 + error.filename = filename;
31 31
32 32 if (options.loc) {
33 33 error.line = options.loc.line;
6 lib/roole.js
@@ -26,17 +26,17 @@ roole.compile = function(input, options, callback) {
26 26 options = {};
27 27 }
28 28
29   - if (options.fileName == null) { options.fileName = ''; }
  29 + if (options.filename == null) { options.filename = ''; }
30 30 if (options.imports == null) { options.imports = {}; }
31 31 if (options.prettyError == null) { options.prettyError = defaults.prettyError; }
32 32
33   - options.imports[options.fileName] = input;
  33 + options.imports[options.filename] = input;
34 34
35 35 if (options.prettyError) {
36 36 var _callback = callback;
37 37 callback = function(error, ast) {
38 38 if (error && error.line) {
39   - input = options.imports[error.fileName];
  39 + input = options.imports[error.filename];
40 40 error.message = formatter.format(error, input);
41 41 }
42 42
34 test/assert.js
@@ -67,7 +67,7 @@ assert.failAt = function(options, input, loc) {
67 67 }
68 68 }
69 69
70   - if (!loc.fileName) { loc.fileName = ''; }
  70 + if (!loc.filename) { loc.filename = ''; }
71 71
72 72 var called = false;
73 73 roole.compile(input, options, function(error) {
@@ -93,8 +93,8 @@ assert.failAt = function(options, input, loc) {
93 93 throw error;
94 94 }
95 95
96   - if (error.fileName !== loc.fileName) {
97   - var message = 'error has file path ' + error.fileName + ' instead of ' + loc.fileName;
  96 + if (error.filename !== loc.filename) {
  97 + var message = 'error has file path ' + error.filename + ' instead of ' + loc.filename;
98 98 error.message = message + ':\n\n' + error.message;
99 99 throw error;
100 100 }
@@ -123,15 +123,15 @@ assert.run = function(cmd, input, output) {
123 123 };
124 124
125 125 if (input.files) {
126   - for (var fileName in input.files) {
127   - var fileContent = input.files[fileName];
128   - fileName = path.join(dir, fileName);
  126 + for (var filename in input.files) {
  127 + var fileContent = input.files[filename];
  128 + filename = path.join(dir, filename);
129 129
130   - if (existsSync(fileName)) {
131   - return callback(new Error("'" + fileName + "' already exists"));
  130 + if (existsSync(filename)) {
  131 + return callback(new Error("'" + filename + "' already exists"));
132 132 }
133 133
134   - var fileDir = path.dirname(fileName);
  134 + var fileDir = path.dirname(filename);
135 135 if (!existsSync(fileDir)) {
136 136 mkdirp.sync(fileDir);
137 137 }
@@ -140,7 +140,7 @@ assert.run = function(cmd, input, output) {
140 140 fileContent = fileContent.join('\n');
141 141 }
142 142
143   - fs.writeFileSync(fileName, fileContent);
  143 + fs.writeFileSync(filename, fileContent);
144 144 }
145 145 }
146 146
@@ -160,26 +160,26 @@ assert.run = function(cmd, input, output) {
160 160 return callback(new Error('stdout is\n"""\n' + stdout + '\n"""\n\ninstead of\n\n"""\n' + output.stdout + '\n"""'));
161 161 }
162 162 } else if (output.files) {
163   - for (var fileName in output.files) {
164   - var fileContent = output.files[fileName];
165   - fileName = path.join(dir, fileName);
  163 + for (var filename in output.files) {
  164 + var fileContent = output.files[filename];
  165 + filename = path.join(dir, filename);
166 166
167 167 if (fileContent === null) {
168   - if (existsSync(fileName)) {
169   - return callback(new Error('"' + fileName + '" is created, which is not supposed to be'));
  168 + if (existsSync(filename)) {
  169 + return callback(new Error('"' + filename + '" is created, which is not supposed to be'));
170 170 }
171 171
172 172 continue;
173 173 }
174 174
175   - var realContent = fs.readFileSync(fileName, 'utf8');
  175 + var realContent = fs.readFileSync(filename, 'utf8');
176 176
177 177 if (Array.isArray(fileContent)) {
178 178 fileContent = fileContent.join('\n');
179 179 }
180 180
181 181 if (realContent !== fileContent) {
182   - return callback(new Error('"' + fileName + '" is\n"""\n' + realContent + '\n"""\n\ninstead of\n\n"""\n' + fileContent + '\n"""'));
  182 + return callback(new Error('"' + filename + '" is\n"""\n' + realContent + '\n"""\n\ninstead of\n\n"""\n' + fileContent + '\n"""'));
183 183 }
184 184 }
185 185 }
2  test/unit/import.js
@@ -218,5 +218,5 @@ test('not allow importing file has syntax error', function() {
218 218 ]
219 219 }}, [
220 220 '@import "base";',
221   - ], {line: 1, column: 7, fileName: 'base.roo'});
  221 + ], {line: 1, column: 7, filename: 'base.roo'});
222 222 });

0 comments on commit e8ef61d

Please sign in to comment.
Something went wrong with that request. Please try again.