diff --git a/build/tasks/build-task.coffee b/build/tasks/build-task.coffee index c606220ad..5ffdf6ce2 100644 --- a/build/tasks/build-task.coffee +++ b/build/tasks/build-task.coffee @@ -21,7 +21,9 @@ module.exports = (grunt) -> mkdir appDir - cp 'atom.sh', path.join(appDir, 'atom.sh') + if process.platform isnt 'win32' + cp 'atom.sh', path.join(appDir, 'atom.sh') + cp 'package.json', path.join(appDir, 'package.json') packageDirectories = [] @@ -149,10 +151,8 @@ module.exports = (grunt) -> grunt.file.copy(sourcePath, path.resolve(appDir, '..', subDirectory, filename)) if process.platform is 'win32' - # Set up chocolatey ignore and gui files - fs.writeFileSync path.join(appDir, 'apm', 'node_modules', 'atom-package-manager', 'bin', 'node.exe.ignore'), '' - fs.writeFileSync path.join(appDir, 'node_modules', 'symbols-view', 'vendor', 'ctags-win32.exe.ignore'), '' - fs.writeFileSync path.join(shellAppDir, 'atom.exe.gui'), '' + cp path.join('resources', 'win', 'atom.cmd'), path.join(shellAppDir, 'resources', 'cli', 'atom.cmd') + cp path.join('resources', 'win', 'atom.js'), path.join(shellAppDir, 'resources', 'cli', 'atom.js') dependencies = ['compile', 'generate-license:save', 'generate-module-cache', 'compile-packages-slug'] dependencies.push('copy-info-plist') if process.platform is 'darwin' diff --git a/resources/win/atom.cmd b/resources/win/atom.cmd new file mode 100644 index 000000000..029763c52 --- /dev/null +++ b/resources/win/atom.cmd @@ -0,0 +1,22 @@ +@echo off + +SET EXPECT_OUTPUT= + +FOR %%a IN (%*) DO ( + IF /I "%%a"=="-f" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="--foreground" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="-h" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="--help" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="-t" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="--test" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="-v" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="--version" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="-w" SET EXPECT_OUTPUT=YES + IF /I "%%a"=="--wait" SET EXPECT_OUTPUT=YES +) + +IF "%EXPECT_OUTPUT%"=="YES" ( + "%~dp0\..\..\atom.exe" %* +) ELSE ( + "%~dp0\..\app\apm\node_modules\atom-package-manager\bin\node.exe" "%~dp0\atom.js" %* +) diff --git a/resources/win/atom.js b/resources/win/atom.js new file mode 100644 index 000000000..df059aa5b --- /dev/null +++ b/resources/win/atom.js @@ -0,0 +1,9 @@ +var path = require('path'); +var spawn = require('child_process').spawn; + +var atomCommandPath = path.resolve(__dirname, '..', '..', 'atom.exe'); +var arguments = process.argv.slice(2); +arguments.unshift('--executed-from', process.cwd()); +var options = {detached: true, stdio: 'ignore'}; +spawn(atomCommandPath, arguments, options); +process.exit(0); diff --git a/src/browser/squirrel-update.coffee b/src/browser/squirrel-update.coffee index e976b15bb..93e0c464d 100644 --- a/src/browser/squirrel-update.coffee +++ b/src/browser/squirrel-update.coffee @@ -3,7 +3,8 @@ ChildProcess = require 'child_process' fs = require 'fs-plus' path = require 'path' -rootAtomFolder = path.resolve(process.execPath, '..', '..') +appFolder = path.resolve(process.execPath, '..') +rootAtomFolder = path.resolve(appFolder, '..') binFolder = path.join(rootAtomFolder, 'bin') updateDotExe = path.join(rootAtomFolder, 'Update.exe') exeName = path.basename(process.execPath) @@ -111,18 +112,12 @@ uninstallContextMenu = (callback) -> addCommandsToPath = (callback) -> installCommands = (callback) -> atomCommandPath = path.join(binFolder, 'atom.cmd') - relativeExePath = path.relative(binFolder, process.execPath) - atomCommand = """ - @echo off - "%~dp0\\#{relativeExePath}" %* - """ + relativeAtomPath = path.relative(binFolder, path.join(appFolder, 'resources', 'cli', 'atom.cmd')) + atomCommand = "@echo off\r\n\"%~dp0\\#{relativeAtomPath}\" %*" apmCommandPath = path.join(binFolder, 'apm.cmd') relativeApmPath = path.relative(binFolder, path.join(process.resourcesPath, 'app', 'apm', 'node_modules', 'atom-package-manager', 'bin', 'apm.cmd')) - apmCommand = """ - @echo off - "%~dp0\\#{relativeApmPath}" %* - """ + apmCommand = "@echo off\r\n\"%~dp0\\#{relativeApmPath}\" %*" fs.writeFile atomCommandPath, atomCommand, -> fs.writeFile apmCommandPath, apmCommand, ->