Comparing version 1.1.4 to 1.1.5
{ | ||
"name": "bundle-me", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Bundles all the files inside the directory", | ||
@@ -9,4 +9,4 @@ "main": "src/index.js", | ||
"start": "node src/index.js", | ||
"test": "mocha", | ||
"jshint": "jshint", | ||
"test": "mocha && npm run lint", | ||
"lint": "jshint", | ||
"clean": "rm -rf bundle-me.js bundle-me.css" | ||
@@ -19,4 +19,9 @@ }, | ||
"allfiles", | ||
"getAllFilenames" | ||
"getAllFilenames", | ||
"extension" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pajaydev/bundle-me.git" | ||
}, | ||
"author": "Ajaykumar Prathap", | ||
@@ -23,0 +28,0 @@ "devDependencies": { |
@@ -5,5 +5,3 @@ 'use strict'; | ||
const fs = require('fs'); | ||
const { join } = require('path'); | ||
function createBundle(options) { | ||
@@ -37,3 +35,7 @@ if (!options) throw new Error("invalid input"); | ||
if (!options) throw new Error("invalid input"); | ||
if (!options.path) throw new Error("please provide valid input folder path"); | ||
if (!options.path){ | ||
options = { | ||
path : options | ||
}; | ||
}; | ||
const sourcePath = path.join(process.cwd(), options.path); | ||
@@ -45,12 +47,7 @@ return iterateFiles(sourcePath, options.extn, []); | ||
const files = getFiles(sourcePath); | ||
fileArray.push(...files); | ||
files.forEach(file => { | ||
if (fs.statSync(file).isDirectory()) { | ||
iterateFiles(file, extn, fileArray); | ||
} | ||
fs.statSync(file).isDirectory() ? iterateFiles(file, extn, fileArray): fileArray.push(file); | ||
}); | ||
if (extn) { | ||
fileArray = fileArray.filter((f) => { | ||
return isExtnValid(f, extn); | ||
}) | ||
fileArray = fileArray.filter((f) => isExtnValid(f, extn)); | ||
} | ||
@@ -63,3 +60,3 @@ return fileArray; | ||
if (fs.statSync(sourcePath).isDirectory()) { | ||
return fs.readdirSync(sourcePath).map(file => join(sourcePath, file)) | ||
return fs.readdirSync(sourcePath).map(file => path.join(sourcePath, file)) | ||
} | ||
@@ -83,3 +80,2 @@ return [sourcePath]; | ||
module.exports = { | ||
@@ -86,0 +82,0 @@ getAllFiles, |
@@ -13,7 +13,7 @@ 'use strict'; | ||
it("Test getAllFiles method", () => { | ||
expect(getAllFiles({ path: 'static' }).length).to.equal(3); | ||
expect(getAllFiles({ path: 'static' }).length).to.equal(4); | ||
}); | ||
it("Test getAllFiles method with extn", () => { | ||
expect(getAllFiles({ path: 'static', extn: 'js' }).length).to.equal(2); | ||
expect(getAllFiles({ path: 'static', extn: 'js' }).length).to.equal(3); | ||
expect(getAllFiles({ path: 'static', extn: 'css' }).length).to.equal(1); | ||
@@ -20,0 +20,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
6745
7
100
1