Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/about/lib/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ module.exports = class About {

this.subscriptions.add(
atom.commands.add('atom-workspace', 'about:view-release-notes', () => {
shell = shell || require('electron').shell;
shell.openExternal(
atom.openExternal(
this.state.updateManager.getReleaseNotesURLForCurrentVersion()
);
})
Expand Down
7 changes: 3 additions & 4 deletions packages/about/lib/components/about-view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { Disposable } = require('atom');
const etch = require('etch');
const { shell } = require('electron');
const AtomLogo = require('./atom-logo');
const EtchComponent = require('../etch-component');

Expand Down Expand Up @@ -29,7 +28,7 @@ module.exports = class AboutView extends EtchComponent {

handleReleaseNotesClick(e) {
e.preventDefault();
shell.openExternal(
atom.openExternal(
this.props.updateManager.getReleaseNotesURLForCurrentVersion()
);
}
Expand All @@ -44,13 +43,13 @@ module.exports = class AboutView extends EtchComponent {

handleTermsOfUseClick(e) {
e.preventDefault();
shell.openExternal('https://atom.io/terms'); //If we use this then this URL will need updating but button disabled (L#182)
atom.openExternal('https://atom.io/terms'); //If we use this then this URL will need updating but button disabled (L#182)
// TODO Update to Privacy Policy once `pulsar-edit.github.io` #161 is resolved
}

handleHowToUpdateClick(e) {
e.preventDefault();
shell.openExternal(
atom.openExternal(
'https://github.com/pulsar-edit/pulsar/tree/master/packages/pulsar-updater#readme'
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/autocomplete-plus/lib/autocomplete-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class AutocompleteManager {
let descriptionContainer = suggestionListView.querySelector('.suggestion-description')
if (descriptionContainer !== null && descriptionContainer.style.display === 'block') {
let descriptionMoreLink = descriptionContainer.querySelector('.suggestion-description-more-link')
require('electron').shell.openExternal(descriptionMoreLink.href)
atom.openExternal(descriptionMoreLink.href)
}
}
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1997,29 +1997,27 @@ defm`
it('triggers openExternal on keybind if there is a description', async () => {
spyOn(provider, 'getSuggestions').andCallFake(() => [{text: 'ab', description: 'it is ab'}])
// eslint-disable-next-line node/no-extraneous-require
let shell = require('electron').shell
spyOn(shell, 'openExternal')
spyOn(atom, 'openExternal')

triggerAutocompletion(editor, true, 'a')
await waitForAutocomplete(editor)

expect(editorView.querySelector('.autocomplete-plus')).toExist()
atom.commands.dispatch(editorView, 'autocomplete-plus:navigate-to-description-more-link')
expect(shell.openExternal).toHaveBeenCalled()
expect(atom.openExternal).toHaveBeenCalled()
})

it('does not trigger openExternal on keybind if there is not a description', async () => {
spyOn(provider, 'getSuggestions').andCallFake(() => [{text: 'ab'}])
// eslint-disable-next-line node/no-extraneous-require
let shell = require('electron').shell
spyOn(shell, 'openExternal')
spyOn(atom, 'openExternal')

triggerAutocompletion(editor, true, 'a')
await waitForAutocomplete(editor)

expect(editorView.querySelector('.autocomplete-plus')).toExist()
atom.commands.dispatch(editorView, 'autocomplete-plus:navigate-to-description-more-link')
expect(shell.openExternal).not.toHaveBeenCalled()
expect(atom.openExternal).not.toHaveBeenCalled()
})
})
})
Expand Down
3 changes: 1 addition & 2 deletions packages/link/lib/link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const url = require('url');
const { shell } = require('electron');
const _ = require('underscore-plus');

const LINK_SCOPE_REGEX = /markup\.underline\.link/;
Expand Down Expand Up @@ -30,7 +29,7 @@ module.exports = {

const { protocol } = url.parse(link);
if (protocol === 'http:' || protocol === 'https:' || protocol === 'atom:') {
shell.openExternal(link);
atom.openExternal(link);
}
},

Expand Down
60 changes: 29 additions & 31 deletions packages/link/spec/link-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { shell } = require('electron');

describe('link package', () => {
beforeEach(async () => {
await atom.packages.activatePackage('language-hyperlink');
Expand All @@ -20,29 +18,29 @@ describe('link package', () => {
editor.setText('// http://github.com ');
await languageMode.atTransactionEnd();

spyOn(shell, 'openExternal');
spyOn(atom, 'openExternal');
atom.commands.dispatch(atom.views.getView(editor), 'link:open');
expect(shell.openExternal).not.toHaveBeenCalled();
expect(atom.openExternal).not.toHaveBeenCalled();

editor.setCursorBufferPosition([0, 4]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).toHaveBeenCalled();
expect(shell.openExternal.argsForCall[0][0]).toBe('http://github.com');
expect(atom.openExternal).toHaveBeenCalled();
expect(atom.openExternal.argsForCall[0][0]).toBe('http://github.com');

shell.openExternal.reset();
atom.openExternal.reset();
editor.setCursorBufferPosition([0, 8]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).toHaveBeenCalled();
expect(shell.openExternal.argsForCall[0][0]).toBe('http://github.com');
expect(atom.openExternal).toHaveBeenCalled();
expect(atom.openExternal.argsForCall[0][0]).toBe('http://github.com');

shell.openExternal.reset();
atom.openExternal.reset();
editor.setCursorBufferPosition([0, 20]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).toHaveBeenCalled();
expect(shell.openExternal.argsForCall[0][0]).toBe('http://github.com');
expect(atom.openExternal).toHaveBeenCalled();
expect(atom.openExternal.argsForCall[0][0]).toBe('http://github.com');
});

// NOTE: I don't think anyone realized that this was a feature. Our
Expand All @@ -57,33 +55,33 @@ describe('link package', () => {
'// atom://core/open/file?filename=sample.js&line=1&column=2 '
);

spyOn(shell, 'openExternal');
spyOn(atom, 'openExternal');
atom.commands.dispatch(atom.views.getView(editor), 'link:open');
expect(shell.openExternal).not.toHaveBeenCalled();
expect(atom.openExternal).not.toHaveBeenCalled();

editor.setCursorBufferPosition([0, 4]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).toHaveBeenCalled();
expect(shell.openExternal.argsForCall[0][0]).toBe(
expect(atom.openExternal).toHaveBeenCalled();
expect(atom.openExternal.argsForCall[0][0]).toBe(
'atom://core/open/file?filename=sample.js&line=1&column=2'
);

shell.openExternal.reset();
atom.openExternal.reset();
editor.setCursorBufferPosition([0, 8]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).toHaveBeenCalled();
expect(shell.openExternal.argsForCall[0][0]).toBe(
expect(atom.openExternal).toHaveBeenCalled();
expect(atom.openExternal.argsForCall[0][0]).toBe(
'atom://core/open/file?filename=sample.js&line=1&column=2'
);

shell.openExternal.reset();
atom.openExternal.reset();
editor.setCursorBufferPosition([0, 59]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).toHaveBeenCalled();
expect(shell.openExternal.argsForCall[0][0]).toBe(
expect(atom.openExternal).toHaveBeenCalled();
expect(atom.openExternal.argsForCall[0][0]).toBe(
'atom://core/open/file?filename=sample.js&line=1&column=2'
);
});
Expand All @@ -106,22 +104,22 @@ you should not [click][her]
// Allow for time for injections to populate
await languageMode.atTransactionEnd();

spyOn(shell, 'openExternal');
spyOn(atom, 'openExternal');
editor.setCursorBufferPosition([0, 0]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');
expect(shell.openExternal).not.toHaveBeenCalled();
expect(atom.openExternal).not.toHaveBeenCalled();

editor.setCursorBufferPosition([0, 19]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).toHaveBeenCalled();
expect(shell.openExternal.argsForCall[0][0]).toBe('http://github.com');
expect(atom.openExternal).toHaveBeenCalled();
expect(atom.openExternal.argsForCall[0][0]).toBe('http://github.com');

shell.openExternal.reset();
atom.openExternal.reset();
editor.setCursorBufferPosition([1, 24]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).not.toHaveBeenCalled();
expect(atom.openExternal).not.toHaveBeenCalled();
}));

it('does not open non http/https/atom links', async () => {
Expand All @@ -130,14 +128,14 @@ you should not [click][her]
const editor = atom.workspace.getActiveTextEditor();
editor.setText('// ftp://github.com\n');

spyOn(shell, 'openExternal');
spyOn(atom, 'openExternal');
atom.commands.dispatch(atom.views.getView(editor), 'link:open');
expect(shell.openExternal).not.toHaveBeenCalled();
expect(atom.openExternal).not.toHaveBeenCalled();

editor.setCursorBufferPosition([0, 5]);
atom.commands.dispatch(atom.views.getView(editor), 'link:open');

expect(shell.openExternal).not.toHaveBeenCalled();
expect(atom.openExternal).not.toHaveBeenCalled();
});
});
});
4 changes: 1 addition & 3 deletions packages/notifications/lib/notification-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*/
let NotificationElement;
const fs = require('fs-plus');
const path = require('path');
const {shell} = require('electron');

const NotificationIssue = require('./notification-issue');
const TemplateHelper = require('./template-helper');
Expand Down Expand Up @@ -264,7 +262,7 @@ Upgrading to the <a href='https://github.com/pulsar-edit/pulsar/releases/tag/v${
e.preventDefault();
issueButton.classList.add('opening');
return this.issue.getIssueUrlForSystem().then(function(issueUrl) {
shell.openExternal(issueUrl);
atom.openExternal(issueUrl);
return issueButton.classList.remove('opening');
});
});
Expand Down
3 changes: 1 addition & 2 deletions packages/open-on-github/lib/github-file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @babel */

import {shell} from 'electron'
import {Range} from 'atom'
import {parse as parseURL} from 'url'
import path from 'path'
Expand Down Expand Up @@ -145,7 +144,7 @@ export default class GitHubFile {

// Internal
openURLInBrowser (url) {
shell.openExternal(url)
atom.openExternal(url)
}

// Internal
Expand Down
3 changes: 1 addition & 2 deletions packages/pulsar-updater/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,9 @@ class PulsarUpdater {

const openWebGitHub = (e) => {
e.preventDefault();
shell ??= shell || require("electron").shell;
let latestVersion = this.cache.getCacheItem("last-update-check")?.latestVersion;
let tagSegment = latestVersion ? `tag/${latestVersion}` : "";
shell.openExternal(`https://github.com/pulsar-edit/pulsar/releases/${tagSegment}`);
atom.openExternal(`https://github.com/pulsar-edit/pulsar/releases/${tagSegment}`);
};

switch (installMethod.installMethod) {
Expand Down
3 changes: 1 addition & 2 deletions packages/settings-view/lib/badge-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import {CompositeDisposable, Disposable} from 'atom'
import etch from 'etch'
import {shell} from 'electron'

export default class BadgeView {
constructor(badge) {
Expand All @@ -18,7 +17,7 @@ export default class BadgeView {
if (!anchor) return
event.stopPropagation()
event.preventDefault()
shell.openExternal(anchor.href)
atom.openExternal(anchor.href)
}

if (this.hasLink()) {
Expand Down
5 changes: 2 additions & 3 deletions packages/settings-view/lib/install-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/** @jsx etch.dom */

import path from 'path'
import electron from 'electron'
import etch from 'etch'
import hostedGitInfo from 'hosted-git-info'

Expand All @@ -28,7 +27,7 @@ export default class InstallPanel {
this.refs.searchEditor.setPlaceholderText('Search packages')
this.searchType = 'packages'
this.disposables.add(
this.packageManager.on('package-install-failed', ({pack, error}) => {
this.packageManager.on('package-install-failed', ({error}) => {
this.refs.searchErrors.appendChild(new ErrorView(this.packageManager, error).element)
})
)
Expand Down Expand Up @@ -303,7 +302,7 @@ export default class InstallPanel {

didClickOpenAtomIo (event) {
event.preventDefault()
electron.shell.openExternal(this.atomIoURL)
atom.openExternal(this.atomIoURL)
}

didClickSearchPackagesButton () {
Expand Down
5 changes: 2 additions & 3 deletions packages/settings-view/lib/package-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/** @jsx etch.dom */

import {CompositeDisposable, Disposable} from 'atom'
import {shell} from 'electron'
import etch from 'etch'
import BadgeView from './badge-view'
import path from 'path'
Expand Down Expand Up @@ -233,14 +232,14 @@ export default class PackageCard {

const packageNameClickHandler = (event) => {
event.stopPropagation()
shell.openExternal(`https://web.pulsar-edit.dev/packages/${this.pack.name}`)
atom.openExternal(`https://web.pulsar-edit.dev/packages/${this.pack.name}`)
}
this.refs.packageName.addEventListener('click', packageNameClickHandler)
this.disposables.add(new Disposable(() => { this.refs.packageName.removeEventListener('click', packageNameClickHandler) }))

const packageAuthorClickHandler = (event) => {
event.stopPropagation()
shell.openExternal(`https://web.pulsar-edit.dev/users/${ownerFromRepository(this.pack.repository)}`) //TODO: Fix - This does not current exist but this will at least be more accurate
atom.openExternal(`https://web.pulsar-edit.dev/users/${ownerFromRepository(this.pack.repository)}`) //TODO: Fix - This does not current exist but this will at least be more accurate
}
this.refs.loginLink.addEventListener('click', packageAuthorClickHandler)
this.disposables.add(new Disposable(() => { this.refs.loginLink.removeEventListener('click', packageAuthorClickHandler) }))
Expand Down
9 changes: 4 additions & 5 deletions packages/settings-view/lib/package-detail-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import url from 'url'

import _ from 'underscore-plus'
import fs from 'fs-plus'
import {shell} from 'electron'
import {CompositeDisposable, Disposable} from 'atom'
import etch from 'etch'

Expand Down Expand Up @@ -49,9 +48,9 @@ export default class PackageDetailView {
const repoUrl = this.packageManager.getRepositoryUrl(this.pack)
if (typeof repoUrl === 'string') {
if (url.parse(repoUrl).pathname === '/pulsar-edit/pulsar') {
shell.openExternal(`${repoUrl}/tree/master/packages/${this.pack.name}`)
atom.openExternal(`${repoUrl}/tree/master/packages/${this.pack.name}`)
} else {
shell.openExternal(repoUrl)
atom.openExternal(repoUrl)
}
}
}
Expand All @@ -62,7 +61,7 @@ export default class PackageDetailView {
event.preventDefault()
let bugUri = this.packageManager.getRepositoryBugUri(this.pack)
if (bugUri) {
shell.openExternal(bugUri)
atom.openExternal(bugUri)
}
}
this.refs.issueButton.addEventListener('click', issueButtonClickHandler)
Expand Down Expand Up @@ -97,7 +96,7 @@ export default class PackageDetailView {

const learnMoreButtonClickHandler = (event) => {
event.preventDefault()
shell.openExternal(`https://web.pulsar-edit.dev/packages/${this.pack.name}`)
atom.openExternal(`https://web.pulsar-edit.dev/packages/${this.pack.name}`)
}
this.refs.learnMoreButton.addEventListener('click', learnMoreButtonClickHandler)
this.disposables.add(new Disposable(() => { this.refs.learnMoreButton.removeEventListener('click', learnMoreButtonClickHandler) }))
Expand Down
Loading
Loading