Socket
Socket
Sign inDemoInstall

editorconfig

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

editorconfig - npm Package Compare versions

Comparing version 0.12.1 to 0.12.2

42

editorconfig.js

@@ -38,2 +38,13 @@ var os = require('os');

function getFilepathRoot(filepath) {
if (path.parse !== undefined) {
// Node.js >= 0.11.15
return path.parse(filepath).root;
}
if (os.platform() === 'win32') {
return path.resolve(filepath).match(/^(\\\\[^\\]+\\)?[^\\]+\\/)[0];
}
return '/';
}
function processMatches(matches, version) {

@@ -68,8 +79,2 @@ // Set indent_size to "tab" if indent_size is unspecified and

};
function getFilepathRoot(filepath) {
if (os.platform() === 'win32') {
return path.resolve(filepath).match(/^[^\\]+\\/)[0];
}
return '/';
}
}

@@ -100,2 +105,7 @@

} catch(e) {}
if (typeof value === 'undefined' || value === null) {
// null and undefined are values specific to JSON (no special meaning
// in editorconfig) & should just be returned as regular strings.
value = String(value);
}
matches[key] = value;

@@ -143,13 +153,17 @@ }

module.exports.parseFromFiles = function (filepath, files, options) {
filepath = path.resolve(filepath);
options = processOptions(options, filepath);
return parseFromFiles(filepath, files, options);
return new Promise (function (resolve, reject) {
filepath = path.resolve(filepath);
options = processOptions(options, filepath);
resolve(parseFromFiles(filepath, files, option));
});
};
module.exports.parse = function (filepath, options) {
filepath = path.resolve(filepath);
options = processOptions(options, filepath);
var filepaths = getConfigFileNames(filepath, options);
var files = readConfigFiles(filepaths);
return parseFromFiles(filepath, files, options);
return new Promise (function (resolve, reject) {
filepath = path.resolve(filepath);
options = processOptions(options, filepath);
var filepaths = getConfigFileNames(filepath, options);
var files = readConfigFiles(filepaths);
resolve(parseFromFiles(filepath, files, options));
});
};

@@ -15,5 +15,5 @@ // Based on iniparser by shockie <https://npmjs.org/package/iniparser>

var regex = {
section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,
param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
comment: /^\s*[#;].*$/
section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,
param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
comment: /^\s*[#;].*$/
};

@@ -27,41 +27,41 @@

*/
module.exports.parse = function(file, callback){
if(!callback){
return;
}
fs.readFile(file, 'utf8', function(err, data){
if(err){
callback(err);
}else{
callback(null, parse(data));
}
});
module.exports.parse = function (file, callback) {
if (!callback) {
return;
}
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
callback(err);
} else {
callback(null, parse(data));
}
});
};
module.exports.parseSync = function(file){
return parse(fs.readFileSync(file, 'utf8'));
module.exports.parseSync = function (file) {
return parse(fs.readFileSync(file, 'utf8'));
};
function parse(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 (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;
}
module.exports.parseString = parse;
{
"name": "editorconfig",
"version": "0.12.1",
"version": "0.12.2",
"description": "EditorConfig File Locator and Interpreter for Node.js",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc