本文整理匯總了TypeScript中opn.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: opn
app.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
opn('http://localhost:5000')
return console.log(`server is listening on ${port}`)
})
示例2: openLinkInBrowser
/**
* Opens the specified URL and appends the specified object (if defined)
* as query string parameters
*/
public static openLinkInBrowser(link: string, args?: any, hash?: string): Thenable<void> {
let qs = [];
if (args) {
// check arguments
for(let name in args) {
if (args.hasOwnProperty(name)) {
qs.push(
name + '=' + encodeURIComponent(args[name])
);
}
}
}
// append the query string if defined
if (qs.length > 0) {
if (link.indexOf('?') > -1) {
link += '&' + qs.join('&');
} else {
link += '?' + qs.join('&');
}
}
// appends the hash directive
if (hash) {
if (hash[0] != '#') {
hash = '#' + hash;
}
link += hash;
}
return opn(link);
}
示例3: reject
server.listen(serveTaskOptions.port, serveTaskOptions.host, (err: any, _stats: any) => {
if (err) {
return reject(err);
}
if (serveTaskOptions.open) {
opn(serverAddress);
}
});
示例4: map
map(buildEvent => {
if (first && options.open) {
first = false;
opn(opnAddress);
}
return buildEvent;
}),
示例5: reject
(err: any, _stats: any) => {
if (err) {
return reject(err);
}
if (serveTaskOptions.open) {
opn(serverAddress + servePath);
}
});
示例6: run
public async run(options: DocCommandSchema & Arguments) {
let searchUrl = `https://angular.io/api?query=${options.keyword}`;
if (options.search) {
searchUrl = `https://www.google.com/search?q=site%3Aangular.io+${options.keyword}`;
}
return opn(searchUrl, {
wait: false,
});
}
示例7: function
server.listen(commandOptions.port, `${commandOptions.host}`, function(err: any, stats: any) {
if (err) {
console.error(err.stack || err);
if (err.details) { console.error(err.details); }
reject(err.details);
} else {
const { open, host, port } = commandOptions;
if (open) {
opn(url.format({ protocol: 'http', hostname: host, port: port.toString() }));
}
}
});
示例8: opn
return Printer.write(results, flags.output, outputPath).then(results => {
if (flags.output === Printer.OutputMode[Printer.OutputMode.html] ||
flags.output === Printer.OutputMode[Printer.OutputMode.domhtml]) {
if (flags.view) {
opn(outputPath, {wait: false});
} else {
log.log('CLI', 'Protip: Run lighthouse with `--view` to immediately open the HTML report in your browser');
}
}
return results;
});
示例9: reject
server.listen(serveTaskOptions.port, `${serveTaskOptions.host}`, (err: any, stats: any) => {
if (err) {
console.error(err.stack || err);
if (err.details) { console.error(err.details); }
reject(err.details);
} else {
const { open, ssl, host, port } = serveTaskOptions;
if (open) {
let protocol = ssl ? 'https' : 'http';
opn(url.format({ protocol: protocol, hostname: host, port: port.toString() }));
}
}
});
示例10: opnWrapper
export function opnWrapper(url, name, bs) {
var options = (function () {
if (_.isString(name)) {
return {app: name};
}
if (Immutable.Map.isMap(name)) {
return name.toJS();
}
return {};
})();
var opn = require("opn");
opn(url, options).catch(function () {
bs.events.emit("browser:error");
});
}