Skip to content

kaizhu256/node-electron-lite

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

electron-lite

this zero-dependency package will download and install the electron (v1.7.13) prebuilt-binary from https://github.com/electron/electron/releases, with a working web-demo

live web demo

  • none

screenshot

travis-ci.org build-status coverage

NPM

build commit status

git-branch : master beta alpha
test-report : test-report test-report test-report
coverage : coverage coverage coverage
build-artifacts : build-artifacts build-artifacts build-artifacts

npmPackageListing

npmPackageDependencyTree

table of contents

  1. cdn download
  2. documentation
  3. quickstart screenshot example
  4. extra screenshots
  5. package.json
  6. changelog of last 50 commits
  7. internal build script
  8. misc

cdn download

documentation

cli help

screenshot

api doc

apidoc

todo

  • upgrade to electron v1.8.x when stable
  • none

changelog for v2018.3.28

  • npm publish v2018.3.28
  • minor update to electron v1.7.13
  • none

this package requires

  • darwin or linux os

additional info

quickstart screenshot example

screenshot

to run this example, follow the instruction in the script below

/*
example.js

this electron script will screenshot the webpage https://electron.atom.io

instruction
    1. save this script as example.js
    2. run the shell command:
        $ npm install electron-lite && \
            printf '{"main":"example.js","name":"undefined","version":"0.0.1"}' > \
            package.json && \
            ./node_modules/.bin/electron . --disable-overlay-scrollbar --enable-logging
    3. view screenshot /tmp/screenshot.testExampleJs.browser..png
*/

/* istanbul instrument in package electron */
/*jslint
    bitwise: true,
    browser: true,
    maxerr: 4,
    maxlen: 100,
    node: true,
    nomen: true,
    regexp: true,
    stupid: true
*/
(function () {
    'use strict';
    var options, modeNext, onNext;
    onNext = function (data) {
        modeNext += 1;
        switch (modeNext) {
        case 1:
            /* istanbul ignore next */
            if (process.env.npm_config_mode_auto_restart) {
                return;
            }
            // wait for electron to init
            require('electron').app.once('ready', onNext);
            break;
        case 2:
            // init options
            options = { frame: false, height: 768, width: 1024, x: 0, y: 0 };
            // init browserWindow;
            options.BrowserWindow = require('electron').BrowserWindow;
            options.browserWindow = new options.BrowserWindow(options);
            // goto next step when webpage is loaded
            options.browserWindow.webContents.once('did-stop-loading', onNext);
            // open url
            options.browserWindow.loadURL('https://electron.atom.io');
            break;
        case 3:
            // screenshot webpage
            options.browserWindow.capturePage(options, onNext);
            break;
        case 4:
            // screenshot
            require('fs').writeFileSync(
                '/tmp/screenshot.testExampleJs.browser..png',
                data.toPng()
            );
            console.log('created screenshot file /tmp/screenshot.testExampleJs.browser..png');
            // exit
            process.exit(0);
            break;
        }
    };
    modeNext = 0;
    onNext();
}());

output from browser

screenshot

output from shell

screenshot

extra screenshots

  1. https://kaizhu256.github.io/node-electron-lite/build/screenshot.buildCi.browser.%252Ftmp%252Fbuild%252Fapidoc.html.png screenshot

  2. https://kaizhu256.github.io/node-electron-lite/build/screenshot.buildCi.browser.%252Ftmp%252Fbuild%252Fcoverage.lib.html.png screenshot

  3. https://kaizhu256.github.io/node-electron-lite/build/screenshot.buildCi.browser.%252Ftmp%252Fbuild%252Ftest-report.html.png screenshot

package.json

{
    "author": "kai zhu <kaizhu256@gmail.com>",
    "bin": {
        "electron": "lib.electron.js"
    },
    "description": "this zero-dependency package will download and install the electron (v1.7.13) prebuilt-binary from https://github.com/electron/electron/releases, with a working web-demo",
    "devDependencies": {
        "utility2": "kaizhu256/node-utility2#alpha"
    },
    "engines": {
        "node": ">=4.0"
    },
    "homepage": "https://github.com/kaizhu256/node-electron-lite",
    "keywords": [
        "electron",
        "headless-browser",
        "screenshot",
        "web-scraper"
    ],
    "license": "MIT",
    "main": "lib.electron.js",
    "name": "electron-lite",
    "nameAliasPublish": "electron-scrape",
    "nameLib": "electron",
    "nameOriginal": "electron-lite",
    "os": [
        "darwin",
        "linux"
    ],
    "repository": {
        "type": "git",
        "url": "https://github.com/kaizhu256/node-electron-lite.git"
    },
    "scripts": {
        "apidocRawCreate": "[ ! -f npm_scripts.sh ] || ./npm_scripts.sh shNpmScriptApidocRawCreate",
        "apidocRawFetch": "[ ! -f npm_scripts.sh ] || ./npm_scripts.sh shNpmScriptApidocRawFetch",
        "build-ci": "utility2 shReadmeTest build_ci.sh",
        "env": "env",
        "heroku-postbuild": "npm uninstall utility2 2>/dev/null; npm install kaizhu256/node-utility2#alpha && utility2 shDeployHeroku",
        "postinstall": "[ ! -f npm_scripts.sh ] || ./npm_scripts.sh shNpmScriptPostinstall",
        "start": "NODE_BINARY=./lib.electron.js PORT=${PORT:-8080} utility2 start test.js",
        "test": "set -e; rm -fr external; npm run postinstall; ./lib.electron.js --version; export NODE_BINARY=./lib.electron.js; utility2 test test.js"
    },
    "version": "2018.3.28"
}

changelog of last 50 commits

screenshot

internal build script

  • build_ci.sh
# build_ci.sh

# this shell script will run the build for this package

shBuildCiAfter() {(set -e
    shDeployCustom
    # shDeployGithub
    # shDeployHeroku
    shReadmeTest example.sh
)}

shBuildCiBefore() {(set -e
    ln -s ../../lib.electron.js node_modules/.bin/electron || true
    shNpmTestPublished
    shReadmeTest example.js
    # screenshot
    cp /tmp/screenshot.*.png "$npm_config_dir_build"
)}

# run shBuildCi
eval $(utility2 source)
shBuildCi

misc

  • this package was created with utility2

About

this zero-dependency package will download and install the electron (v2.0.18) prebuilt-binary from https://github.com/electron/electron/releases

Resources

License

Stars

Watchers

Forks

Packages

No packages published