Comparing version
@@ -18,8 +18,9 @@ "use strict"; | ||
/** | ||
* Loads files from a `directory` and executes a `callback` for each. | ||
* Load files from a `directory` and execute a `callback` for each. | ||
* | ||
* @param {string} directory - directory to load files from | ||
* @param {function} callback - callback to execute on each file | ||
* @param {string} directory directory to load files from | ||
* @param {function} callback callback to execute on each file | ||
* @return {void} | ||
*/ | ||
exports.default = function (directory, callback) { | ||
function call(directory, callback) { | ||
_fs2.default.readdirSync(_path2.default.resolve(process.cwd(), directory)).filter(function (file) { | ||
@@ -30,4 +31,5 @@ return file.indexOf(".") !== 0; | ||
}); | ||
}; | ||
} | ||
exports.default = call; | ||
module.exports = exports["default"]; |
{ | ||
"name": "call-dir", | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"callback", | ||
"require", | ||
"directory", | ||
"require", | ||
"load", | ||
"multiple", | ||
"files" | ||
"filter", | ||
"files", | ||
"fs" | ||
], | ||
@@ -24,14 +23,24 @@ "description": "Loads files from a directory and executes a callback for each", | ||
"devDependencies": { | ||
"flow-bin": "^0.56.0", | ||
"babel": "^6.23.0", | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.0.1", | ||
"babel-preset-flow": "^6.23.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-preset-stage-0": "^6.24.1", | ||
"babel-plugin-add-module-exports": "^0.2.1" | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"eslint": "^4.8.0", | ||
"eslint-config-google": "^0.9.1", | ||
"eslint-plugin-flowtype": "^2.35.0", | ||
"eslint-plugin-import": "^2.7.0" | ||
}, | ||
"scripts": { | ||
"test": "npm run eslint && npm run flow", | ||
"flow": "flow", | ||
"clean": "rm -rf dist", | ||
"build": "babel src -d dist", | ||
"watch": "babel src -d dist -w", | ||
"prepare": "npm run clean && npm run build" | ||
"eslint": "node_modules/.bin/eslint --fix src", | ||
"prepare": "npm run clean && npm run test && npm run build" | ||
} | ||
} |
@@ -5,3 +5,3 @@ <div align="center"> | ||
[](https://greenkeeper.io/) | ||
[](https://travis-ci.org/Bartozzz/Qilin/) | ||
[](https://travis-ci.org/Bartozzz/call-dir/) | ||
[](https://www.npmjs.com/package/call-dir) | ||
@@ -32,5 +32,5 @@ [](https://www.npmjs.com/package/call-dir) | ||
// You can load multiple modules easily: | ||
// You can initialize modules from a directory easily: | ||
load( "./models", path => require( path )( some, variables, ...here ) ); | ||
load( "./routes", path => require( path )( some, variables, ...here ) ); | ||
``` |
@@ -1,14 +0,19 @@ | ||
import fs from "fs"; | ||
// @flow | ||
import fs from "fs"; | ||
import path from "path"; | ||
/** | ||
* Loads files from a `directory` and executes a `callback` for each. | ||
* Load files from a `directory` and execute a `callback` for each. | ||
* | ||
* @param {string} directory - directory to load files from | ||
* @param {function} callback - callback to execute on each file | ||
* @param {string} directory directory to load files from | ||
* @param {function} callback callback to execute on each file | ||
* @return {void} | ||
*/ | ||
export default ( directory, callback ) => { | ||
fs.readdirSync( path.resolve( process.cwd(), directory ) ) | ||
.filter( file => file.indexOf( "." ) !== 0 ) | ||
.forEach( file => callback( path.join( directory, file ), file ) ); | ||
}; | ||
function call(directory: string, callback: (string, string) => any): void { | ||
fs.readdirSync(path.resolve(process.cwd(), directory)) | ||
.filter((file) => file.indexOf(".") !== 0) | ||
.forEach((file) => callback(path.join(directory, file), file)); | ||
} | ||
export default call; |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6526
24.64%12
33.33%68
94.29%1
-50%12
140%