Skip to content

Commit 712f825

Browse files
committed
support custom output filename
1 parent 7928f75 commit 712f825

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@ Creates lasso-analyze.html in your project directory.
3535
1. Bundled file is created under "build/static/" folder. Run the CLI as shown below
3636

3737
```bash
38-
lasso-analyzer <--bundle path-->
38+
lasso-analyzer <--bundle path--> <--outputFilename-->
3939
```
40+
Creates outputFilename.html in your project structure.
4041

4142
For Example:
4243

43-
a. Options to provide direct Output js file.
44+
a. Analyze js bundle file.
4445
``` bash
4546
lasso-analyzer static/build.js
4647
```
4748
or
4849

49-
b. Options to provide Output Folder like this, it iterates entire folder and create lasso-analyze.html.
50+
b. Analyze all the files inside particular folder and create lasso-analyze.html.
5051

5152
``` bash
5253
lasso-analyzer static

bin/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ const lassoAnalyzer = require('../src/index');
66
const { createBundle } = require('bundle-me');
77
const argv = parseArgs(process.argv.slice(2));
88
const borderX = `${Array(30).join('-')}\n`;
9+
// extract input file.
910
const input = argv._ || [];
11+
// extract output file.
12+
let outputFile = parseArgs(process.argv).output;
1013

1114
if (input.length > 0) {
1215
input.map((fileName) => {
1316
createBundle({ path: fileName, outputPath: 'lasso-analyze.js' }).createBundle;
14-
lassoAnalyzer('lasso-analyze.js');
17+
lassoAnalyzer('lasso-analyze.js', outputFile);
1518
});
16-
const startLog = `${borderX}` + `lasso-analyze.html is created \n` +
19+
outputFile = outputFile || 'lasso-analyze';
20+
const startLog = `${borderX}` + `${outputFile}.html is created \n` +
1721
`${borderX}`;
1822
console.log(startLog);
1923
} else {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lasso-analyzer",
3-
"version": "1.3.2",
3+
"version": "1.4.0",
44
"description": "A tool to analyze the bundle created by Lasso",
55
"main": "src/index.js",
66
"bin": {

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ function bundleAnalyzer(fileName, bundleName) {
2121
if (!bundleName) bundleName = "lasso-analyze";
2222
fs.writeFileSync(getOutputHTML(bundleName), html);
2323
// clean files
24-
cleanFiles(bundleName);
24+
cleanFiles();
2525
};
2626

27-
function cleanFiles(bundleName) {
28-
const jsFile = process.cwd() + '/' + bundleName + '.js';
27+
function cleanFiles() {
28+
const jsFile = process.cwd() + '/lasso-analyze.js';
2929
const jsonFile = process.cwd() + '/lasso-stats.json';
3030
// remove bundle js
3131
if (fs.existsSync(jsFile)) {

src/lasso-analyzer-plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const lasso = require('lasso');
1+
'use strict';
2+
23
const fs = require('fs');
34
const path = require('path');
45
const lassoAnalyzer = require('./index');

0 commit comments

Comments
 (0)