editorconfig
Advanced tools
Comparing version 0.14.2 to 0.15.0
144
lib/ini.js
@@ -0,9 +1,41 @@ | ||
"use strict"; | ||
// Based on iniparser by shockie <https://npmjs.org/package/iniparser> | ||
/* | ||
* get the file handler | ||
*/ | ||
var fs = require('fs'); | ||
/* | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fs = require("fs"); | ||
/** | ||
* define the possible values: | ||
@@ -15,50 +47,54 @@ * section: [section] | ||
var regex = { | ||
section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/, | ||
param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/, | ||
comment: /^\s*[#;].*$/ | ||
section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/, | ||
param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/, | ||
comment: /^\s*[#;].*$/, | ||
}; | ||
/* | ||
* parses a .ini file | ||
* @param: {String} file, the location of the .ini file | ||
* @param: {Function} callback, the function that will be called when parsing is done | ||
* @return: none | ||
/** | ||
* Parses an .ini file | ||
* @param file The location of the .ini file | ||
*/ | ||
exports.parse = function (file, callback) { | ||
if (!callback) { | ||
return; | ||
} | ||
fs.readFile(file, 'utf8', function (err, data) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
callback(null, parse(data)); | ||
} | ||
}); | ||
}; | ||
exports.parseSync = function (file) { | ||
return parse(fs.readFileSync(file, 'utf8')); | ||
}; | ||
exports.parseString = function (data) { | ||
var sectionBody = {}; | ||
var sectionName = null; | ||
var value = [[sectionName, sectionBody]]; | ||
var lines = data.split(/\r\n|\r|\n/); | ||
lines.forEach(function (line) { | ||
var match; | ||
if (regex.comment.test(line)) { | ||
return; | ||
} else if (regex.param.test(line)) { | ||
match = line.match(regex.param); | ||
sectionBody[match[1]] = match[2]; | ||
} else if (regex.section.test(line)) { | ||
match = line.match(regex.section); | ||
sectionName = match[1]; | ||
sectionBody = {}; | ||
value.push([sectionName, sectionBody]); | ||
} | ||
}); | ||
return value; | ||
}; | ||
function parse(file) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
fs.readFile(file, 'utf8', function (err, data) { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
resolve(parseString(data)); | ||
}); | ||
})]; | ||
}); | ||
}); | ||
} | ||
exports.parse = parse; | ||
function parseSync(file) { | ||
return parseString(fs.readFileSync(file, 'utf8')); | ||
} | ||
exports.parseSync = parseSync; | ||
function parseString(data) { | ||
var sectionBody = {}; | ||
var sectionName = null; | ||
var value = [[sectionName, sectionBody]]; | ||
var lines = data.split(/\r\n|\r|\n/); | ||
lines.forEach(function (line) { | ||
var match; | ||
if (regex.comment.test(line)) { | ||
return; | ||
} | ||
if (regex.param.test(line)) { | ||
match = line.match(regex.param); | ||
sectionBody[match[1]] = | ||
match[2]; | ||
} | ||
else if (regex.section.test(line)) { | ||
match = line.match(regex.section); | ||
sectionName = match[1]; | ||
sectionBody = {}; | ||
value.push([sectionName, sectionBody]); | ||
} | ||
}); | ||
return value; | ||
} | ||
exports.parseString = parseString; |
{ | ||
"name": "editorconfig", | ||
"version": "0.14.2", | ||
"version": "0.15.0", | ||
"description": "EditorConfig File Locator and Interpreter for Node.js", | ||
@@ -9,3 +9,3 @@ "keywords": [ | ||
], | ||
"main": "editorconfig.js", | ||
"main": "index.js", | ||
"bin": { | ||
@@ -24,6 +24,15 @@ "editorconfig": "bin/editorconfig" | ||
"scripts": { | ||
"pretest": "cmake .", | ||
"test": "npm run lint && ctest .", | ||
"test-verbose": "npm run lint && ctest -VV --output-on-failure .", | ||
"lint": "eclint check --indent_size ignore editorconfig.js README.md \"bin/**\" \"lib/**\"" | ||
"clean": "rimraf dist", | ||
"prebuild": "npm run clean", | ||
"build": "tsc", | ||
"pretest": "npm run lint && npm run build && npm run copy && cmake .", | ||
"test": "ctest .", | ||
"pretest:ci": "npm run pretest", | ||
"test:ci": "ctest -VV --output-on-failure .", | ||
"lint": "npm run eclint && npm run tslint", | ||
"eclint": "eclint check --indent_size ignore \"src/**\"", | ||
"tslint": "tslint --project tslint.json", | ||
"copy": "cpy package.json .npmignore LICENSE README.md CHANGELOG.md dist && cpy src/bin/* dist/bin && cpy src/lib/fnmatch*.* dist/lib", | ||
"prepub": "npm run lint && npm run build && npm run copy", | ||
"pub": "npm publish ./dist" | ||
}, | ||
@@ -38,13 +47,19 @@ "repository": { | ||
"dependencies": { | ||
"bluebird": "^3.0.5", | ||
"commander": "^2.9.0", | ||
"lru-cache": "^3.2.0", | ||
"semver": "^5.1.0", | ||
"@types/commander": "^2.11.0", | ||
"@types/semver": "^5.4.0", | ||
"commander": "^2.11.0", | ||
"lru-cache": "^4.1.1", | ||
"semver": "^5.4.1", | ||
"sigmund": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"eclint": "^1.1.5", | ||
"mocha": "^2.3.4", | ||
"should": "^7.1.1" | ||
"@types/mocha": "^2.2.43", | ||
"cpy-cli": "^1.0.1", | ||
"eclint": "^2.4.3", | ||
"mocha": "^4.0.1", | ||
"rimraf": "^2.6.2", | ||
"should": "^13.1.2", | ||
"tslint": "^5.7.0", | ||
"typescript": "^2.5.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
61460
13
1507
6
8
+ Added@types/commander@^2.11.0
+ Added@types/semver@^5.4.0
+ Added@types/commander@2.12.2(transitive)
+ Added@types/semver@5.5.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedbluebird@^3.0.5
- Removedbluebird@3.7.2(transitive)
- Removedlru-cache@3.2.0(transitive)
Updatedcommander@^2.11.0
Updatedlru-cache@^4.1.1
Updatedsemver@^5.4.1