Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bundle-me

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bundle-me - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

bundle-me.js

7

package.json
{
"name": "bundle-me",
"version": "1.0.0",
"version": "1.0.1",
"description": "Bundles all the files inside the directory",

@@ -9,4 +9,5 @@ "main": "src/index.js",

"start": "node src/index.js",
"test": "npm run jshint",
"jshint": "jshint"
"test": "mocha",
"jshint": "jshint",
"clean": "rm -rf bundle-me.js bundle-me.css"
},

@@ -13,0 +14,0 @@ "keywords": [

@@ -1,2 +0,2 @@

# bundle-me [![Build Status](https://travis-ci.org/ajay2507/bundle-me.svg?branch=master)](https://travis-ci.org/ajay2507/bundle-me)
# bundle-me [![Build Status](https://travis-ci.org/pajaydev/bundle-me.svg?branch=master)](https://travis-ci.org/pajaydev/bundle-me)

@@ -16,6 +16,6 @@

```js
const bundleMe = require('bundle-me');
const {createBundle} = require('bundle-me');
try {
bundleMe({ path: filePath, extn: 'js', outputPath: 'example/bundle.js' }).createBundle; // creates bundle and returns the output path.
createBundle({ path: filePath, extn: 'js', outputPath: 'example/bundle.js'})// creates bundle and returns the output path.
}

@@ -30,6 +30,7 @@ catch (error) {

```js
const bundleMe = require('bundle-me');
const { getAllFiles } = require('bundle-me');
try {
bundleMe({ path: filePath, extn: 'js', outputPath: 'example/bundle.js' }).files; // returns array of files in directory.
getAllFiles({ path: filePath });
// returns array of files in the given file path.
}

@@ -59,2 +60,3 @@ catch (error) {

## Example
https://github.com/pajaydev/bundle-me/tree/master/example

@@ -61,0 +63,0 @@ ## License

@@ -7,14 +7,10 @@ 'use strict';

function bundleResource(options) {
function createBundle(options) {
if (!options) throw new Error("invalid input");
if (!options.path) throw new Error("please provide valid input folder path");
//if (!Array.isArray(options.extn)) await Promise.reject(new Error("Extension 'extn' should be an array"));
const sourcePath = path.join(process.cwd(), options.path);
const outputPath = createOutputFile(options);
console.log(outputPath);
return {
createBundle: walkThrough(sourcePath, outputPath, options.extn),
files: getAllFiles(sourcePath, options.extn)
}
};
return walkThrough(sourcePath, outputPath, options.extn);
}

@@ -24,2 +20,3 @@ // iterate through all the files.

const files = getFiles(sourcePath);
console.log(files);
files.forEach(file => {

@@ -40,3 +37,10 @@ if (fs.statSync(file).isDirectory()) {

the array of files. */
function getAllFiles(sourcePath, extn, fileArray = []) {
function getAllFiles(options, fileArray = []) {
if (!options) throw new Error("invalid input");
if (!options.path) throw new Error("please provide valid input folder path");
const sourcePath = path.join(process.cwd(), options.path);
return iterateFiles(sourcePath, options.extn, []);
}
function iterateFiles(sourcePath, extn, fileArray = []) {
const files = getFiles(sourcePath);

@@ -46,3 +50,3 @@ fileArray.push(...files);

if (fs.statSync(file).isDirectory()) {
getAllFiles(file, extn, fileArray);
iterateFiles(file, extn, fileArray);
}

@@ -58,5 +62,8 @@ });

// get all the file names in the given directory
const getFiles = (sourcePath) => {
return fs.readdirSync(sourcePath).map(file => join(sourcePath, file))
if (fs.statSync(sourcePath).isDirectory()) {
return fs.readdirSync(sourcePath).map(file => join(sourcePath, file))
}
return [sourcePath];
};

@@ -72,3 +79,4 @@

const createOutputFile = (options) => {
const outputPath = options.outputPath ? path.resolve(options.outputPath) : path.resolve(process.cwd(), 'bundle-me.' + options.extn);
const extn = options.extn ? options.extn : 'js';
const outputPath = options.outputPath ? path.resolve(options.outputPath) : path.resolve(process.cwd(), 'bundle-me.' + extn);
fs.writeFileSync(outputPath, '');

@@ -79,2 +87,7 @@ return outputPath;

module.exports = bundleResource;
module.exports = {
getAllFiles,
createBundle
};
createBundle({ path: 'static/a' });
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