mirror of
https://github.com/atom/atom.git
synced 2026-01-25 23:08:18 -05:00
Merge pull request #19028 from atom/aw/revert-launch-scenario-change
Revert launch scenario changes
This commit is contained in:
35
atom.sh
35
atom.sh
@@ -26,10 +26,20 @@ esac
|
||||
|
||||
export ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=true
|
||||
|
||||
while getopts ":wtfvh-:" opt; do
|
||||
ATOM_ADD=false
|
||||
ATOM_NEW_WINDOW=false
|
||||
EXIT_CODE_OVERRIDE=
|
||||
|
||||
while getopts ":anwtfvh-:" opt; do
|
||||
case "$opt" in
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
add)
|
||||
ATOM_ADD=true
|
||||
;;
|
||||
new-window)
|
||||
ATOM_NEW_WINDOW=true
|
||||
;;
|
||||
wait)
|
||||
WAIT=1
|
||||
;;
|
||||
@@ -45,6 +55,12 @@ while getopts ":wtfvh-:" opt; do
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
a)
|
||||
ATOM_ADD=true
|
||||
;;
|
||||
n)
|
||||
ATOM_NEW_WINDOW=true
|
||||
;;
|
||||
w)
|
||||
WAIT=1
|
||||
;;
|
||||
@@ -58,6 +74,11 @@ while getopts ":wtfvh-:" opt; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${ATOM_ADD}" = "true" ] && [ "${ATOM_NEW_WINDOW}" = "true" ]; then
|
||||
EXPECT_OUTPUT=1
|
||||
EXIT_CODE_OVERRIDE=1
|
||||
fi
|
||||
|
||||
if [ $REDIRECT_STDERR ]; then
|
||||
exec 2> /dev/null
|
||||
fi
|
||||
@@ -115,7 +136,11 @@ if [ $OS == 'Mac' ]; then
|
||||
|
||||
if [ $EXPECT_OUTPUT ]; then
|
||||
"$ATOM_PATH/$ATOM_APP_NAME/Contents/MacOS/$ATOM_EXECUTABLE_NAME" --executed-from="$(pwd)" --pid=$$ "$@"
|
||||
exit $?
|
||||
if [ $? -eq 0 ] && [ -n "${EXIT_CODE_OVERRIDE}" ]; then
|
||||
exit "${EXIT_CODE_OVERRIDE}"
|
||||
else
|
||||
exit $?
|
||||
fi
|
||||
else
|
||||
open -a "$ATOM_PATH/$ATOM_APP_NAME" -n --args --executed-from="$(pwd)" --pid=$$ --path-environment="$PATH" "$@"
|
||||
fi
|
||||
@@ -144,7 +169,11 @@ elif [ $OS == 'Linux' ]; then
|
||||
|
||||
if [ $EXPECT_OUTPUT ]; then
|
||||
"$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@"
|
||||
exit $?
|
||||
if [ $? -eq 0 ] && [ -n "${EXIT_CODE_OVERRIDE}" ]; then
|
||||
exit "${EXIT_CODE_OVERRIDE}"
|
||||
else
|
||||
exit $?
|
||||
fi
|
||||
else
|
||||
(
|
||||
nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > "$ATOM_HOME/nohup.out" 2>&1
|
||||
|
||||
@@ -4,6 +4,8 @@ SET EXPECT_OUTPUT=
|
||||
SET WAIT=
|
||||
SET PSARGS=%*
|
||||
SET ELECTRON_ENABLE_LOGGING=
|
||||
SET ATOM_ADD=
|
||||
SET ATOM_NEW_WINDOW=
|
||||
|
||||
FOR %%a IN (%*) DO (
|
||||
IF /I "%%a"=="-f" SET EXPECT_OUTPUT=YES
|
||||
@@ -17,6 +19,10 @@ FOR %%a IN (%*) DO (
|
||||
IF /I "%%a"=="-v" SET EXPECT_OUTPUT=YES
|
||||
IF /I "%%a"=="--version" SET EXPECT_OUTPUT=YES
|
||||
IF /I "%%a"=="--enable-electron-logging" SET ELECTRON_ENABLE_LOGGING=YES
|
||||
IF /I "%%a"=="-a" SET ATOM_ADD=YES
|
||||
IF /I "%%a"=="--add" SET ATOM_ADD=YES
|
||||
IF /I "%%a"=="-n" SET ATOM_NEW_WINDOW=YES
|
||||
IF /I "%%a"=="--new-window" SET ATOM_NEW_WINDOW=YES
|
||||
IF /I "%%a"=="-w" (
|
||||
SET EXPECT_OUTPUT=YES
|
||||
SET WAIT=YES
|
||||
@@ -27,6 +33,12 @@ FOR %%a IN (%*) DO (
|
||||
)
|
||||
)
|
||||
|
||||
IF "%ATOM_ADD%"=="YES" (
|
||||
IF "%ATOM_NEW_WINDOW%"=="YES" (
|
||||
SET EXPECT_OUTPUT=YES
|
||||
)
|
||||
)
|
||||
|
||||
IF "%EXPECT_OUTPUT%"=="YES" (
|
||||
IF "%WAIT%"=="YES" (
|
||||
powershell -noexit "Start-Process -FilePath \"%~dp0\..\..\atom.exe\" -ArgumentList \"--pid=$pid $env:PSARGS\" ; wait-event"
|
||||
|
||||
@@ -230,6 +230,7 @@ class AtomApplication extends EventEmitter {
|
||||
pidToKillWhenClosed,
|
||||
devMode,
|
||||
safeMode,
|
||||
newWindow,
|
||||
logFile,
|
||||
profileStartup,
|
||||
timeout,
|
||||
@@ -267,6 +268,7 @@ class AtomApplication extends EventEmitter {
|
||||
foldersToOpen,
|
||||
executedFrom,
|
||||
pidToKillWhenClosed,
|
||||
newWindow,
|
||||
devMode,
|
||||
safeMode,
|
||||
profileStartup,
|
||||
@@ -280,6 +282,7 @@ class AtomApplication extends EventEmitter {
|
||||
// Always open a editor window if this is the first instance of Atom.
|
||||
return this.openPath({
|
||||
pidToKillWhenClosed,
|
||||
newWindow,
|
||||
devMode,
|
||||
safeMode,
|
||||
profileStartup,
|
||||
@@ -791,6 +794,7 @@ class AtomApplication extends EventEmitter {
|
||||
// options -
|
||||
// :pathToOpen - The file path to open
|
||||
// :pidToKillWhenClosed - The integer of the pid to kill
|
||||
// :newWindow - Boolean of whether this should be opened in a new window.
|
||||
// :devMode - Boolean to control the opened window's dev mode.
|
||||
// :safeMode - Boolean to control the opened window's safe mode.
|
||||
// :profileStartup - Boolean to control creating a profile of the startup time.
|
||||
@@ -799,6 +803,7 @@ class AtomApplication extends EventEmitter {
|
||||
openPath ({
|
||||
pathToOpen,
|
||||
pidToKillWhenClosed,
|
||||
newWindow,
|
||||
devMode,
|
||||
safeMode,
|
||||
profileStartup,
|
||||
@@ -810,6 +815,7 @@ class AtomApplication extends EventEmitter {
|
||||
return this.openPaths({
|
||||
pathsToOpen: [pathToOpen],
|
||||
pidToKillWhenClosed,
|
||||
newWindow,
|
||||
devMode,
|
||||
safeMode,
|
||||
profileStartup,
|
||||
@@ -826,6 +832,7 @@ class AtomApplication extends EventEmitter {
|
||||
// :pathsToOpen - The array of file paths to open
|
||||
// :foldersToOpen - An array of additional paths to open that must be existing directories
|
||||
// :pidToKillWhenClosed - The integer of the pid to kill
|
||||
// :newWindow - Boolean of whether this should be opened in a new window.
|
||||
// :devMode - Boolean to control the opened window's dev mode.
|
||||
// :safeMode - Boolean to control the opened window's safe mode.
|
||||
// :windowDimensions - Object with height and width keys.
|
||||
@@ -836,6 +843,7 @@ class AtomApplication extends EventEmitter {
|
||||
foldersToOpen,
|
||||
executedFrom,
|
||||
pidToKillWhenClosed,
|
||||
newWindow,
|
||||
devMode,
|
||||
safeMode,
|
||||
windowDimensions,
|
||||
@@ -878,13 +886,14 @@ class AtomApplication extends EventEmitter {
|
||||
const normalizedPathsToOpen = locationsToOpen.map(location => location.pathToOpen).filter(Boolean)
|
||||
|
||||
let existingWindow
|
||||
if (addToLastWindow && normalizedPathsToOpen.length > 0) {
|
||||
if (!newWindow && normalizedPathsToOpen.length > 0) {
|
||||
existingWindow = this.windowForPaths(normalizedPathsToOpen, devMode)
|
||||
if (!existingWindow) {
|
||||
let lastWindow = window || this.getLastFocusedWindow()
|
||||
if (lastWindow && lastWindow.devMode === devMode) {
|
||||
existingWindow = lastWindow
|
||||
}
|
||||
}
|
||||
|
||||
if (addToLastWindow && !existingWindow) {
|
||||
let lastWindow = window || this.getLastFocusedWindow()
|
||||
if (lastWindow && lastWindow.devMode === devMode) {
|
||||
existingWindow = lastWindow
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,16 +15,13 @@ module.exports = function parseCommandLine (processArgs) {
|
||||
atom [options] [path ...]
|
||||
atom file[:line[:column]]
|
||||
|
||||
If no arguments are given and no Atom windows are already open, restore all windows
|
||||
from the previous editing session. Use "atom --new-window" to open a single empty
|
||||
Atom window instead.
|
||||
One or more paths to files or folders may be specified. If there is an
|
||||
existing Atom window that contains all of the given folders, the paths
|
||||
will be opened in that window. Otherwise, they will be opened in a new
|
||||
window.
|
||||
|
||||
If no arguments are given and at least one Atom window is open, open a new, empty
|
||||
Atom window.
|
||||
|
||||
One or more paths to files or folders may be specified. All paths will be opened
|
||||
in a new Atom window. Each file may be opened at the desired line (and optionally
|
||||
column) by appending the numbers after the file name, e.g. \`atom file:5:8\`.
|
||||
A file may be opened at the desired line (and optionally column) by
|
||||
appending the numbers right after the file name, e.g. \`atom file:5:8\`.
|
||||
|
||||
Paths that start with \`atom://\` will be interpreted as URLs.
|
||||
|
||||
@@ -43,7 +40,7 @@ module.exports = function parseCommandLine (processArgs) {
|
||||
options.alias('f', 'foreground').boolean('f').describe('f', 'Keep the main process in the foreground.')
|
||||
options.alias('h', 'help').boolean('h').describe('h', 'Print this usage message.')
|
||||
options.alias('l', 'log-file').string('l').describe('l', 'Log all output to file.')
|
||||
options.alias('n', 'new-window').boolean('n').describe('n', 'Launch an empty Atom window instead of restoring previous session.')
|
||||
options.alias('n', 'new-window').boolean('n').describe('n', 'Open a new window.')
|
||||
options.boolean('profile-startup').describe('profile-startup', 'Create a profile of the startup execution time.')
|
||||
options.alias('r', 'resource-path').string('r').describe('r', 'Set the path to the Atom source directory and enable dev-mode.')
|
||||
options.boolean('safe').describe(
|
||||
@@ -108,6 +105,16 @@ module.exports = function parseCommandLine (processArgs) {
|
||||
executedFrom = process.cwd()
|
||||
}
|
||||
|
||||
if (newWindow && addToLastWindow) {
|
||||
process.stderr.write(
|
||||
`Only one of the --add and --new-window options may be specified at the same time.\n\n${options.help()}`,
|
||||
)
|
||||
|
||||
// Exiting the main process with a nonzero exit code on MacOS causes the app open to fail with the mysterious
|
||||
// message "LSOpenURLsWithRole() failed for the application /Applications/Atom Dev.app with error -10810."
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
let pidToKillWhenClosed = null
|
||||
if (args['wait']) {
|
||||
pidToKillWhenClosed = args['pid']
|
||||
|
||||
Reference in New Issue
Block a user