electron-terminal-open
Open App from Command Line Interface for Electron App.
Last updated a year ago by akameco .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install electron-terminal-open 
SYNC missed versions from official npm registry.

electron-terminal-open Build Status

Open App from Command Line Interface for Electron.

Install

$ npm install --save electron-terminal-open

Usage

require electron.

'use strict';
const {BrowserWindow, app} = require('electron');
const parseArgs = require('minimist');
const electronTerminalOpen = require('electron-terminal-open');

let mainWindow;

function createMainWindow() {
	const win = new BrowserWindow({
		title: 'sample-app',
		width: 400,
		height: 500
	});

	if (process.env.NODE_ENV === 'development') {
		win.openDevTools();
	}

	win.loadURL(`https://kangax.github.io/compat-table/es6/`);
	win.on('closed', () => {
		mainWindow = null;
	});

	return win;
}

const args = parseArgs(process.argv.slice(1));

if (args.h || args.help) {
	console.log(`help sample`);
	process.exit(0); // eslint-disable-line
}

if (args.v || args.version) {
	console.log(app.getName(), app.getVersion());
	process.exit(0); // eslint-disable-line
}

app.on('ready', () => {
	electronTerminalOpen(app).then(() => {
		mainWindow = createMainWindow();
	}).catch(err => {
		console.log(err);
	});
});

app.on('window-all-closed', () => {
	if (process.platform !== 'darwin') {
		app.quit();
	}
});


See example.

Support

Add executed-from prop to process.args.

$ pwd
/a/b/c
$ sample-app .
args['executed-from'] // => /a/b/c

API

electronTerminalOpen(app, [options])

app

Type: object

electron.app

options

bundleId

Type: string
Default: com.electron.${app.getName()}

app-bundle-id

License

MIT © akameco

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |