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.1.0

test/index.js

7

package.json
{
"name": "bundle-me",
"version": "1.0.0",
"version": "1.1.0",
"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": [

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

```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.
}

@@ -36,0 +37,0 @@ catch (error) {

@@ -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);
}

@@ -39,3 +35,10 @@ // iterate through all the files.

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);

@@ -45,3 +48,3 @@ fileArray.push(...files);

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

@@ -70,3 +73,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, '');

@@ -77,2 +81,5 @@ return outputPath;

module.exports = bundleResource;
module.exports = {
getAllFiles,
createBundle
};
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