本文整理汇总了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");
});
}