Skip to content

Commit

Permalink
support opening a file in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
pajaydev committed Jan 16, 2020
1 parent 712f825 commit bd134b4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ require('lasso').configure({
]
});
```
Creates lasso-analyze.html in your project directory.


<p align="center">
<img alt="lasso-analyzer" src="https://raw.githubusercontent.com/ajay2507/lasso-analyzer/master/example/lasso-analyze.png" width="512">
</p>

## Usage as CLI ##

1. Bundled file is created under "build/static/" folder. Run the CLI as shown below

```bash
lasso-analyzer <--bundle path--> <--outputFilename-->
lasso-analyzer <--bundle path--> --output <--output filename-->
```
Creates outputFilename.html in your project structure.

```bash
Options:
--output To change the generated output filename. (default - lasso-analyze.html)
```

For Example:

a. Analyze js bundle file.
Expand All @@ -60,6 +59,12 @@ open lasso-analyze.html
```
3. It shows you a treemap visualization as shown below.

## Output
Creates lasso-analyze.html in your project directory.

<p align="center">
<img alt="lasso-analyzer" src="https://raw.githubusercontent.com/ajay2507/lasso-analyzer/master/example/lasso-analyze.png" width="512">
</p>

## Issues ##
Free feel to create bug or propose improvements.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lasso-analyzer",
"version": "1.4.0",
"version": "1.4.1",
"description": "A tool to analyze the bundle created by Lasso",
"main": "src/index.js",
"bin": {
Expand All @@ -14,7 +14,8 @@
},
"dependencies": {
"bundle-me": "^1.1.4",
"lasso-unpack": "1.0.2"
"lasso-unpack": "1.0.2",
"opener": "^1.5.1"
},
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs');
const path = require('path');
const lassoUnpack = require('lasso-unpack');
const opener = require('opener');
const Tree = require('./tree');

function bundleAnalyzer(fileName, bundleName) {
Expand All @@ -20,6 +21,8 @@ function bundleAnalyzer(fileName, bundleName) {
const html = generateHTML(tree);
if (!bundleName) bundleName = "lasso-analyze";
fs.writeFileSync(getOutputHTML(bundleName), html);
// open the browser with generated html
opener(getOutputHTML(bundleName));
// clean files
cleanFiles();
};
Expand Down
1 change: 0 additions & 1 deletion src/lasso-analyzer-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module.exports = (lasso, config) => {
if (bundlePath) {
lassoAnalyzer(bundlePath, bundleName);
}

}
});
const endLog = `${borderX}` + `Created lasso-analyze.html in your project structure \n` +
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ once@^1.3.0:
dependencies:
wrappy "1"

opener@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.1.tgz#6d2f0e77f1a0af0032aca716c2c1fbb8e7e8abed"
integrity sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA==

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
Expand Down

0 comments on commit bd134b4

Please sign in to comment.