Gangmax Blog

single-file-cli

Make sure you have “Node.js” installed and run the following command:

1
2
3
4
# Create a directory and run the following command
mkdir single-file-test
cd single-file-test
npm install single-file-cli

Then you should be able to run it such as:

1
2
3
4
5
6
7
# Indicate the browser application location with the "--browser-executable-path" argument.
npx single-file https://github.com/gildas-lormeau/single-file-cli single-file-cli.html \
--browser-executable-path "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

# For Linux, you can run something similar:
npx single-file https://github.com/gildas-lormeau/single-file-cli single-file-cli.html \
--browser-executable-path "/snap/bin/chromium"

Note that, to run the commands above, you need to have “chrome” or “chromium” installed, and set the application location in the command.

For Firefox, I didn’t get a command to run successfully, even with the web driver. Here is the content I tried.


If you don’t want to use browser, you can use WebDriver instead, such as “geckodriver“. Download it from here. The command looks like below:

1
2
3
4
5
6
7
8
9
10
npx single-file https://github.com/gildas-lormeau/single-file-cli single-file-cli.html \
--browser-executable-path "/Applications/Firefox.app/Contents/MacOS/firefox" \
--web-driver-executable-path ./geckodriver

npx single-file https://github.com/gildas-lormeau/single-file-cli single-file-cli.html \
--browser-executable-path ./geckodriver

npx single-file https://github.com/gildas-lormeau/single-file-cli single-file-cli.html \
--back-end "webdriver-gecko"

Download “webdriver-chromium” from here.

1
2
npx single-file https://github.com/gildas-lormeau/single-file-cli single-file-cli.html \
--browser-executable-path ./chromedriver

Comments