{"id":15391042,"url":"https://github.com/quramy/nirvana-js","last_synced_at":"2026-03-04T17:31:17.689Z","repository":{"id":66208025,"uuid":"99932171","full_name":"Quramy/nirvana-js","owner":"Quramy","description":":zap: JavaScript file runner using Electron","archived":false,"fork":false,"pushed_at":"2020-06-02T21:42:13.000Z","size":3539,"stargazers_count":9,"open_issues_count":25,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T22:39:00.073Z","etag":null,"topics":["electron","test-runner"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Quramy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-10T14:29:43.000Z","updated_at":"2021-03-12T04:31:38.000Z","dependencies_parsed_at":"2023-02-20T21:46:22.731Z","dependency_job_id":null,"html_url":"https://github.com/Quramy/nirvana-js","commit_stats":{"total_commits":60,"total_committers":2,"mean_commits":30.0,"dds":"0.23333333333333328","last_synced_commit":"a60d00b1b092e7b345c7d335a491ed7c7aaf878c"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Fnirvana-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Fnirvana-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Fnirvana-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quramy%2Fnirvana-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Quramy","download_url":"https://codeload.github.com/Quramy/nirvana-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167410,"owners_count":21223503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","test-runner"],"created_at":"2024-10-01T15:09:44.569Z","updated_at":"2026-03-04T17:31:17.630Z","avatar_url":"https://github.com/Quramy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![Nirvana](./logo.png)\n\n[![CircleCI](https://circleci.com/gh/Quramy/nirvana-js.svg?style=svg)](https://circleci.com/gh/Quramy/nirvana-js)\n[![npm version](https://badge.fury.io/js/nirvana-js.svg)](https://badge.fury.io/js/nirvana-js)\n[![Greenkeeper badge](https://badges.greenkeeper.io/Quramy/nirvana-js.svg)](https://greenkeeper.io/)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Quramy/nirvana-js/master/LICENSE)\n\nJavaScript runner using Electron. It provides easy DOM manipulation with Node.js scripting :space_invader:.\n\n## Getting started\n\n```sh\n$ npm -g istall electron nirvana-js\n```\n\nThen, write a script:\n\n```js\n// your-script.js\nconsole.log(document.querySelector('body').innerHTML);\n```\n\nFinally exec the script with `nirvana` command :zap:\n\n```sh\n$ nirvana your-script.js\n```\n\n## Install\n\n```sh\nnpm -g install electron nirvana-js\n```\n\nor\n\n```sh\nyarn global add electron nirvana-js\n```\n\n## Usage\n\n```sh\nnirvana [option] your-javascript.js [script2 script3 ...]\n```\n\n### CLI Options\n\n- `c`, `config` : Configuration file path. See [Configuration File](#configuration-file) section at the below.\n- `d`, `debug` : Run debug mode. It's equivalent to `--watch --show`.\n- `b`, `base-path` : The root path location to be used to resolve from.\n- `w`, `watch` : Watch script files and reload window when they are changed.\n- `v`, `verbose`: Display debug logging messages.\n- `q`, `quiet` : Suppress logging messages.\n- `init` : Generate configuration file.\n- `show` : Whether to desplay browser windows.\n- `custom-context-file`: HTML context file path.\n- `concurrency` : How many windows Nirvana launches in parallel. Default `4`.\n- `noCaptureConsole` : Suppress to capture logging message in browser.\n- `noTimeout` : Suppress closing browser window via timeout.\n\n### Configuration File\nYou can configure nirvana-js using a configuration JavaScript file. Executing `nirvana --init` the configuration file `nirvana.conf.js` is created. For example:\n\n```js\n'use strict';\n\nmodule.exports = {\n  // scripts: [\"a.js\", \"b.js\"],       // Script files to run. Also glob syntax is available e.g. \"*.spec.js\"\n  watch: false,                       // Watch script files and reload window when they are changed.\n  concurrency: 4,                     // How many windows Nirvana launches in parallel.\n  captureConsole: true,               // Whether to capture logging message in browser.\n  // browserNoActivityTimeout: 2000,   // Time period to close window [msec]. If you not want timeout closing, set zero.\n  // contextFile: \"my-context.html\",  // HTML context file.\n  \n  // Electron BrowserWindow constructor option\n  // If you want detail see https://electron.atom.io/docs/api/browser-window/#new-browserwindowoptions.\n  windowOption: {\n    show: false,\n    width: 800,\n    height: 600,\n    webPreferences: {\n      // If you use custom preload script, load 'nirvana-js/preload' in your preload script.\n      // preload: 'preload.js'\n    },\n  },\n};\n```\n\n## Client Utility Functions\nIn scripts to run on nirvana-js, some utility functions are available. For example:\n\n```js\nconst { screenshot } = require('nirvana-js');\n\nfunction yourFunc() {\n  doSomething();\n  screenshot('my-capture.png');\n}\n```\n\n\u003c!-- doc --\u003e\n\u003c!-- THIS DOCUMENT IS AUTOMATICALLY GENERATED FROM src/*.ts --\u003e\n\u003c!-- Please edit src/*.ts and `npm run build:docs:api` --\u003e\n\n\n### Interface\n\n```typescript\nexport declare function isNirvana(): boolean;\nexport declare function getCurrentWindow(): Electron.BrowserWindow | undefined;\nexport declare function exit(code?: number): void;\nexport declare function screenshot(fname: string): Promise\u003cvoid\u003e;\n```\n\n\n#### `export declare function isNirvana(): boolean;`\n\n\n\nTell whether the platform is running on nirvana-js.\n\n\n#### `export declare function getCurrentWindow(): Electron.BrowserWindow | undefined;`\n\n\n\nGet the current browser window.\n\n\n\u003cb\u003ereturn\u003c/b\u003e A Electron's BrowserWindow object\n\n\n#### `export declare function exit(code?: number): void;`\n\n\n\nClose the current browser process immediately.\n\n\n\u003cb\u003eparam\u003c/b\u003e code: Exit code.\n\n\n#### `export declare function screenshot(fname: string): Promise\u003cvoid\u003e;`\n\n\n\nCaptures a snapshot of the current window.\n\n\n\u003cb\u003eparam\u003c/b\u003e fname: The location of captured PNG file.\n\n\n\n\u003c!-- end:doc --\u003e\n\n### Tips\n#### When is browserWindow closed ?\nBy default, nirvana-js's main process is capturing browser windows' logging events. And if no logging event occurs for a certain period of time(specified `browserNoActivityTimeout`), the main process closes the browser window. If you want to suppress timeout closing, set `--no-timeout` CLI option. Or set `0` to `browserNoActivityTimeout` in nivana.conf.js.\n\nIf you want to close browserWindows manually, you should call the `exit` function included [client library](#export-declare-function-exitcode-number-void).\n\n#### How to run testing framework ?\nIt's so easy. See example/jasmine .\n\n#### Capture CPU profile of Node.js script\nRun with `--debug` and launch Chrome's devtools in the window, you can capture CPU profile or performance timeline of your Node.js script.\n\n## License\nMIT. See license file under this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquramy%2Fnirvana-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquramy%2Fnirvana-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquramy%2Fnirvana-js/lists"}