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.2 to 0.13.0

cmake_install.cmake

118

editorconfig.js
var os = require('os');
var path = require('path');
var fs = require('fs');
var util = require('util');
var Promise = require('bluebird');
var whenReadFile = Promise.promisify(require('fs').readFile);
var whenReadFile = Promise.promisify(fs.readFile);

@@ -80,2 +82,30 @@ var minimatch = require('./lib/fnmatch');

function buildFullGlob(pathPrefix, glob) {
switch (glob.indexOf('/')) {
case -1: glob = "**/" + glob; break;
case 0: glob = glob.substring(1); break;
}
return path.join(pathPrefix, glob);
}
function extendProps(props, options) {
for (var key in options) {
var value = options[key];
key = key.toLowerCase();
if (knownProps[key]) {
value = value.toLowerCase();
}
try {
value = JSON.parse(value);
} 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);
}
props[key] = value;
}
return props;
}
function parseFromFiles(filepath, files, options) {

@@ -89,24 +119,5 @@ return getConfigsForFiles(files).then(function (configs) {

if (!glob) return;
switch (glob.indexOf('/')) {
case -1: glob = "**/" + glob; break;
case 0: glob = glob.substring(1); break;
}
var fullGlob = path.join(pathPrefix, glob);
var fullGlob = buildFullGlob(pathPrefix, glob);
if (!fnmatch(filepath, fullGlob)) return;
for (var key in options) {
var value = options[key];
key = key.toLowerCase();
if (knownProps[key]) {
value = value.toLowerCase();
}
try {
value = JSON.parse(value);
} 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;
}
matches = extendProps(matches, options);
});

@@ -119,2 +130,19 @@ return matches;

function parseFromFilesSync(filepath, files, options) {
var configs = getConfigsForFilesSync(files);
configs.reverse();
var matches = {};
configs.forEach(function(config) {
var pathPrefix = path.dirname(config.name);
config.contents.forEach(function(section) {
var glob = section[0], options = section[1];
if (!glob) return;
var fullGlob = buildFullGlob(pathPrefix, glob);
if (!fnmatch(filepath, fullGlob)) return;
matches = extendProps(matches, options);
});
});
return processMatches(matches, options.version);
}
function StopReduce(array) {

@@ -142,2 +170,18 @@ this.array = array;

function getConfigsForFilesSync(files) {
var configs = [];
for (var i in files) {
var file = files[i];
var contents = iniparser.parseString(file.contents);
configs.push({
name: file.name,
contents: contents
});
if ((contents[0][1].root || '').toLowerCase() === 'true') {
break;
}
};
return configs;
}
function readConfigFiles(filepaths) {

@@ -153,2 +197,16 @@ return Promise.map(filepaths, function (path) {

function readConfigFilesSync(filepaths) {
var files = [];
var file;
filepaths.forEach(function(filepath) {
try {
file = fs.readFileSync(filepath, 'utf8');
} catch (e) {
file = '';
}
files.push({name: filepath, contents: file});
});
return files;
}
module.exports.parseFromFiles = function (filepath, files, options) {

@@ -158,6 +216,12 @@ return new Promise (function (resolve, reject) {

options = processOptions(options, filepath);
resolve(parseFromFiles(filepath, files, option));
resolve(parseFromFiles(filepath, files, options));
});
};
module.exports.parseFromFilesSync = function (filepath, files, options) {
filepath = path.resolve(filepath);
options = processOptions(options, filepath);
return parseFromFilesSync(filepath, files, options);
};
module.exports.parse = function (filepath, options) {

@@ -172,1 +236,9 @@ return new Promise (function (resolve, reject) {

};
module.exports.parseSync = function (filepath, options) {
filepath = path.resolve(filepath);
options = processOptions(options, filepath);
var filepaths = getConfigFileNames(filepath, options);
var files = readConfigFilesSync(filepaths);
return parseFromFilesSync(filepath, files, options);
};

14

package.json
{
"name": "editorconfig",
"version": "0.12.2",
"version": "0.13.0",
"description": "EditorConfig File Locator and Interpreter for Node.js",

@@ -12,3 +12,3 @@ "keywords": [

"Hong Xu (topbug.net)",
"Jed Hunsaker <jed.hunsaker[at]gmail.com>",
"Jed Mao (https://github.com/jedmao/)",
"Trey Hunner (http://treyhunner.com)"

@@ -22,5 +22,5 @@ ],

"pretest": "cmake .",
"test": "ctest .",
"test-verbose": "ctest -VV --output-on-failure .",
"codepaint": "codepainter xform -e **/**.js"
"test": "npm run lint && ctest .",
"test-verbose": "npm run lint && ctest -VV --output-on-failure .",
"lint": "node_modules/.bin/eclint check --indent_size ignore editorconfig.js README.md \"bin/**\" \"lib/**\""
},

@@ -44,4 +44,6 @@ "repository": {

"devDependencies": {
"codepainter": "^0.4.4"
"eclint": "^0.2.6",
"mocha": "^2.3.3",
"should": "^7.1.0"
}
}
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