+16
| language: node_js | ||
| os: | ||
| - linux | ||
| - windows | ||
| - osx | ||
| node_js: | ||
| - "stable" | ||
| - "6.4.0" | ||
| - "6.2.2" | ||
| - "4.5.0" | ||
| - "4.0.0" | ||
| sudo: false | ||
| script: | ||
| - npm test | ||
| after_success: | ||
| - npm run coverage |
| // Place your settings in this file to overwrite default and user settings. | ||
| { | ||
| "files.exclude": { | ||
| "**/node_modules": false, | ||
| "node_modules": true | ||
| } | ||
| } |
| 'use strict'; | ||
| const npmfiles = require('../../index'); | ||
| const pResolve = require('path').resolve; | ||
| const fixturePath = pResolve(__dirname + '/../fixtures'); | ||
| const expectedResults = { | ||
| simple: [ | ||
| `${fixturePath}/simple/node_modules/first/first.js`, | ||
| `${fixturePath}/simple/node_modules/second/second.js` | ||
| ], | ||
| arrayfiles: [ | ||
| `${fixturePath}/arrayfiles/node_modules/first/first1.js`, | ||
| `${fixturePath}/arrayfiles/node_modules/first/first2.js`, | ||
| `${fixturePath}/arrayfiles/node_modules/second/second1.js`, | ||
| `${fixturePath}/arrayfiles/node_modules/second/second2.js` | ||
| ], | ||
| 'incl-dev': [ | ||
| `${fixturePath}/incl-dev/node_modules/first/first.js`, | ||
| `${fixturePath}/incl-dev/node_modules/second/second.js` | ||
| ], | ||
| }; | ||
| const getConfig = function getConfig(folder){ | ||
| return {nodeModulesPath: `${fixturePath}/${folder}/node_modules`, packageJsonPath: `${fixturePath}/${folder}/package.json`}; | ||
| }; | ||
| describe('NPM files', () => { | ||
| it('Returns main file declared in the modules own package.json', () => { | ||
| const testType = 'simple'; | ||
| let resultFiles = npmfiles(getConfig(testType)); | ||
| expect(resultFiles).toEqual(expectedResults[testType]); | ||
| }); | ||
| it('Doesn\'t return non existing main entries', () => { | ||
| const testType = 'noexist'; | ||
| let resultFiles = npmfiles(getConfig(testType)); | ||
| expect(resultFiles).toEqual([]); | ||
| }); | ||
| it('Returns main file declared in the modules own package.json as array', () => { | ||
| const testType = 'arrayfiles'; | ||
| let resultFiles = npmfiles(getConfig(testType)); | ||
| expect(resultFiles).toEqual(expectedResults[testType]); | ||
| }); | ||
| it('Returns devDependendencies as well if specified as an option', () => { | ||
| const testType = 'incl-dev'; | ||
| let conf = getConfig(testType); | ||
| conf.includeDev = true; | ||
| let resultFiles = npmfiles(conf); | ||
| expect(resultFiles).toEqual(expectedResults[testType]); | ||
| }); | ||
| }); |
| { | ||
| "dependencies": { | ||
| "first": "*", | ||
| "second": "*" | ||
| }, | ||
| "overrides": { | ||
| "first": { | ||
| "main": [ | ||
| "first1.js", "first2.js" | ||
| ] | ||
| }, | ||
| "second": { | ||
| "main": [ | ||
| "second1.js", "second2.js" | ||
| ] | ||
| } | ||
| } | ||
| } |
| { | ||
| "dependencies": { | ||
| "first": "*" | ||
| }, | ||
| "devDependencies": { | ||
| "second": "*" | ||
| } | ||
| } |
| { | ||
| "dependencies": { | ||
| "first": "*", | ||
| "second": "*" | ||
| } | ||
| } |
| { | ||
| "dependencies": { | ||
| "first": "*", | ||
| "second": "*" | ||
| } | ||
| } |
+3
-1
@@ -84,3 +84,5 @@ var fs = require('fs'); | ||
| } else if(json.main){ | ||
| files.push(path.resolve(modulePath + "/" + json.main)); | ||
| files = files.concat( | ||
| glob.sync(path.resolve(modulePath + "/" + json.main)) | ||
| ); | ||
| } | ||
@@ -87,0 +89,0 @@ |
+7
-2
| { | ||
| "name": "npmfiles", | ||
| "version": "0.1.0", | ||
| "version": "0.1.1", | ||
| "description": "Get all main files for your project's NPM modules", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| "test": "jest --coverage", | ||
| "coverage": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
| }, | ||
@@ -28,3 +29,7 @@ "repository": { | ||
| "glob": "^7.1.1" | ||
| }, | ||
| "devDependencies": { | ||
| "coveralls": "^2.13.1", | ||
| "jest": "^20.0.4" | ||
| } | ||
| } |
+2
-0
| npmfiles | ||
| ================ | ||
| [](https://travis-ci.org/cosminlupu/npmfiles) [](https://coveralls.io/github/cosminlupu/npmfiles?branch=master) | ||
| - [Inspiration](#inspiration) | ||
@@ -5,0 +7,0 @@ - [Usage](#usage) |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
10400
46.46%11
175%126
75%1
-50%154
1.32%2
Infinity%