Skip to content

Commit cb5b954

Browse files
author
Gabriel Schulhof
committed
Converter: Disambiguate references to "path"
PR-URL: #106 Reviewed-By: Michael Dawson <[email protected]>
1 parent 73ff802 commit cb5b954

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tools/conversion.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs');
2+
const path = require('path');
23

34
const args = process.argv.slice(2);
45
const dir = args[0];
@@ -222,21 +223,20 @@ var SourceFileOperations = [
222223
];
223224

224225
var paths = listFiles(dir);
225-
paths.forEach(function(path) {
226-
var filename = path.split('\\').pop().split('/').pop();
226+
paths.forEach(function(dirEntry) {
227+
var filename = dirEntry.split('\\').pop().split('/').pop();
227228

228229
// Check whether the file is a source file or a config file
229230
// then execute function accordingly
230231
var sourcePattern = /.+\.h|.+\.cc|.+\.cpp/;
231232
if (sourcePattern.test(filename)) {
232-
convertFile(path, SourceFileOperations);
233+
convertFile(dirEntry, SourceFileOperations);
233234
} else if (ConfigFileOperations[filename] != null) {
234-
convertFile(path, ConfigFileOperations[filename]);
235+
convertFile(dirEntry, ConfigFileOperations[filename]);
235236
}
236237
});
237238

238239
function listFiles(dir, filelist) {
239-
var path = path || require('path');
240240
files = fs.readdirSync(dir);
241241
filelist = filelist || [];
242242
files.forEach(function(file) {
@@ -257,13 +257,13 @@ function convert(content, operations) {
257257
return content;
258258
}
259259

260-
function convertFile(path, operations) {
261-
fs.readFile(path, "utf-8", function (err, file) {
260+
function convertFile(fileName, operations) {
261+
fs.readFile(fileName, "utf-8", function (err, file) {
262262
if (err) throw err;
263263

264264
file = convert(file, operations);
265265

266-
fs.writeFile(path, file, function(err){
266+
fs.writeFile(fileName, file, function(err){
267267
if (err) throw err;
268268
});
269269
});

0 commit comments

Comments
 (0)