editorconfig 0.13.2 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
File without changes
@@ -68,6 +68,11 @@ promise.then(function onFulfilled(result) {
68
68
 
69
69
  Synchronous version of `editorconfig.parse()`.
70
70
 
71
+ #### parseString(fileContent)
72
+
73
+ The `parse()` function above uses `parseString()` under the hood. If you have your file contents
74
+ just pass it to `parseString()` and it'll return the same results as `parse()`.
75
+
71
76
  #### parseFromFiles(filePath, configs[, options])
72
77
 
73
78
  options is an object with the following defaults:
@@ -1,13 +1,13 @@
1
+ var Promise = require('bluebird');
2
+ var fs = require('fs');
1
3
  var os = require('os');
2
4
  var path = require('path');
3
- var fs = require('fs');
5
+ var semver = require('semver');
4
6
  var util = require('util');
5
- var Promise = require('bluebird');
6
7
  var whenReadFile = Promise.promisify(fs.readFile);
7
8
 
8
- var minimatch = require('./lib/fnmatch');
9
9
  var iniparser = require('./lib/ini');
10
- var Version = require('./lib/version');
10
+ var minimatch = require('./lib/fnmatch');
11
11
  var pkg = require('./package.json');
12
12
 
13
13
  var knownProps = [
@@ -52,7 +52,7 @@ function processMatches(matches, version) {
52
52
  // Set indent_size to "tab" if indent_size is unspecified and
53
53
  // indent_style is set to "tab".
54
54
  if ("indent_style" in matches && matches.indent_style === "tab" &&
55
- !("indent_size" in matches) && version.gte(new Version(0, 10))) {
55
+ !("indent_size" in matches) && semver.gte(version, "0.10.0")) {
56
56
  matches.indent_size = "tab";
57
57
  }
58
58
 
@@ -74,7 +74,7 @@ function processOptions(options, filepath) {
74
74
  options = options || {};
75
75
  return {
76
76
  config: options.config || '.editorconfig',
77
- version: new Version(options.version || pkg.version),
77
+ version: options.version || pkg.version,
78
78
  root: path.resolve(options.root || getFilepathRoot(filepath))
79
79
  };
80
80
  }
File without changes
@@ -23,7 +23,7 @@ var regex = {
23
23
  * @param: {Function} callback, the function that will be called when parsing is done
24
24
  * @return: none
25
25
  */
26
- module.exports.parse = function (file, callback) {
26
+ exports.parse = function (file, callback) {
27
27
  if (!callback) {
28
28
  return;
29
29
  }
@@ -36,11 +36,11 @@ module.exports.parse = function (file, callback) {
36
36
  });
37
37
  };
38
38
 
39
- module.exports.parseSync = function (file) {
39
+ exports.parseSync = function (file) {
40
40
  return parse(fs.readFileSync(file, 'utf8'));
41
41
  };
42
42
 
43
- function parse (data) {
43
+ exports.parseString = function (data) {
44
44
  var sectionBody = {};
45
45
  var sectionName = null;
46
46
  var value = [[sectionName, sectionBody]];
@@ -60,6 +60,4 @@ function parse (data) {
60
60
  }
61
61
  });
62
62
  return value;
63
- }
64
-
65
- module.exports.parseString = parse;
63
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "editorconfig",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "EditorConfig File Locator and Interpreter for Node.js",
5
5
  "keywords": [
6
6
  "editorconfig",
@@ -31,14 +31,12 @@
31
31
  },
32
32
  "bugs": "https://github.com/editorconfig/editorconfig-core-js/issues",
33
33
  "author": "EditorConfig Team",
34
- "license": {
35
- "type": "MIT",
36
- "url": "http://editorconfig.mit-license.org/2012"
37
- },
34
+ "license": "MIT",
38
35
  "dependencies": {
39
36
  "bluebird": "^3.0.5",
40
37
  "commander": "^2.9.0",
41
38
  "lru-cache": "^3.2.0",
39
+ "semver": "^5.1.0",
42
40
  "sigmund": "^1.0.1"
43
41
  },
44
42
  "devDependencies": {
@@ -1,14 +0,0 @@
1
- ; http://editorconfig.org
2
-
3
- root = true
4
-
5
- [*]
6
- indent_style = space
7
- indent_size = 2
8
- end_of_line = lf
9
- charset = utf-8
10
- trim_trailing_whitespace = true
11
- insert_final_newline = true
12
-
13
- [*.md]
14
- indent_size = 4
@@ -1,2 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=lf
@@ -1,10 +0,0 @@
1
- node_modules/
2
- CTest*
3
- *.sln
4
- *.vcxproj*
5
- *.log
6
- [Tt]ests/
7
- Makefile
8
- *.cmake
9
- /CMakeFiles/
10
- /CMakeCache.txt
@@ -1,12 +0,0 @@
1
- node_modules/
2
- CMake*
3
- CTest*
4
- *.sln
5
- *.vcxproj*
6
- *.log
7
- [Tt]est*/
8
- Makefile
9
- .editorconfig
10
- .gitattributes
11
- .npmignore
12
- .travis.yml
@@ -1,18 +0,0 @@
1
- sudo: false
2
-
3
- language: node_js
4
-
5
- node_js:
6
- - '0.10'
7
- - '0.12'
8
-
9
- before_script:
10
- - npm run pretest
11
-
12
- script:
13
- - npm run test-verbose
14
-
15
- notifications:
16
- email:
17
- on_success: change
18
- on_failure: always
@@ -1,16 +0,0 @@
1
- # This file is used for testing only
2
-
3
- # To perform the test, run `cmake .` at the root of the project tree followed
4
- # by `ctest .`
5
-
6
- cmake_minimum_required(VERSION 2.6)
7
-
8
- # Do not check any compiler
9
- project(editorconfig-core-js NONE)
10
-
11
- set(NODE node CACHE STRING "Node.js command")
12
-
13
- enable_testing()
14
-
15
- set(EDITORCONFIG_CMD ${NODE} ${PROJECT_SOURCE_DIR}/bin/editorconfig)
16
- add_subdirectory(tests)
@@ -1,48 +0,0 @@
1
- function Version(version) {
2
- var args = arguments;
3
- this.components = typeof version === "string" ?
4
- version.split(".").map(function(x){return parseInt(x, 10);}) :
5
- Object.keys(arguments).map(function(k){return args[k];});
6
-
7
- var len = this.components.length;
8
- this.major = len ? this.components[0] : 0;
9
- this.minor = len > 1 ? this.components[1] : 0;
10
- this.build = len > 2 ? this.components[2] : 0;
11
- this.revision = len > 3 ? this.components[3] : 0;
12
-
13
- if (typeof version !== "string") {
14
- return;
15
- }
16
-
17
- var ext = version.split("-");
18
- if (ext.length === 2) {
19
- this.configuration = ext[1];
20
- }
21
- }
22
-
23
- Version.prototype = {
24
- toString: function() {
25
- var version = this.components.join(".");
26
- if (typeof this.configuration !== "undefined") {
27
- version += "-" + this.configuration;
28
- }
29
- return version;
30
- },
31
- gte: function(other){
32
- if (this.major < other.major) {
33
- return false;
34
- }
35
- if (this.minor < other.minor) {
36
- return false;
37
- }
38
- if (this.build < other.build) {
39
- return false;
40
- }
41
- if (this.revision < other.revision) {
42
- return false;
43
- }
44
- return true;
45
- }
46
- };
47
-
48
- module.exports = Version;
File without changes
@@ -1,84 +0,0 @@
1
- var editorconfig = require('../');
2
- var fs = require('fs');
3
- var path = require('path');
4
- var should = require('should');
5
-
6
- describe('parse', function() {
7
- it('async', function() {
8
- var expected = {
9
- indent_style: 'space',
10
- indent_size: 2,
11
- end_of_line: 'lf',
12
- charset: 'utf-8',
13
- trim_trailing_whitespace: true,
14
- insert_final_newline: true,
15
- tab_width: 2
16
- };
17
- var target = path.join(__dirname, '/app.js');
18
- var promise = editorconfig.parse(target);
19
- return promise.then(function onFulfilled(result) {
20
- expected.should.eql(result);
21
- });
22
- });
23
-
24
- it('sync', function() {
25
- var expected = {
26
- indent_style: 'space',
27
- indent_size: 2,
28
- end_of_line: 'lf',
29
- charset: 'utf-8',
30
- trim_trailing_whitespace: true,
31
- insert_final_newline: true,
32
- tab_width: 2
33
- };
34
- var target = path.join(__dirname, '/app.js');
35
- expected.should.eql(editorconfig.parseSync(target));
36
- });
37
- });
38
-
39
- describe('parseFromFiles', function() {
40
- it('async', function() {
41
- var expected = {
42
- indent_style: 'space',
43
- indent_size: 2,
44
- tab_width: 2,
45
- end_of_line: 'lf',
46
- charset: 'utf-8',
47
- trim_trailing_whitespace: true,
48
- insert_final_newline: true,
49
- };
50
- var configs = [];
51
- var configPath = path.resolve(__dirname, '../.editorconfig');
52
- var config = {
53
- name: configPath,
54
- contents: fs.readFileSync(configPath, 'utf8')
55
- };
56
- configs.push(config);
57
- var target = path.join(__dirname, '/app.js');
58
- var promise = editorconfig.parseFromFiles(target, configs);
59
- return promise.then(function onFulfilled(result) {
60
- expected.should.eql(result);
61
- });
62
- });
63
-
64
- it('sync', function() {
65
- var expected = {
66
- indent_style: 'space',
67
- indent_size: 2,
68
- tab_width: 2,
69
- end_of_line: 'lf',
70
- charset: 'utf-8',
71
- trim_trailing_whitespace: true,
72
- insert_final_newline: true,
73
- };
74
- var configs = [];
75
- var configPath = path.resolve(__dirname, '../.editorconfig');
76
- var config = {
77
- name: configPath,
78
- contents: fs.readFileSync(configPath, 'utf8')
79
- };
80
- configs.push(config);
81
- var target = path.join(__dirname, '/app.js');
82
- expected.should.eql(editorconfig.parseFromFilesSync(target, configs));
83
- });
84
- });