mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Merge pull request #1473 from atom/cz-windows-start
Fix grunt install on Windows
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
"rcedit": "~0.1.2",
|
||||
"request": "~2.27.0",
|
||||
"rimraf": "~2.2.2",
|
||||
"runas": "~0.3.0",
|
||||
"unzip": "~0.1.9",
|
||||
"vm-compatibility-layer": "~0.1.0",
|
||||
"walkdir": "0.0.7"
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
path = require 'path'
|
||||
|
||||
module.exports = (grunt) ->
|
||||
{cp, mkdir, rm} = require('./task-helpers')(grunt)
|
||||
{cp, mkdir, rm, spawn} = require('./task-helpers')(grunt)
|
||||
|
||||
grunt.registerTask 'install', 'Install the built application', ->
|
||||
installDir = grunt.config.get('atom.installDir')
|
||||
shellAppDir = grunt.config.get('atom.shellAppDir')
|
||||
rm installDir
|
||||
mkdir path.dirname(installDir)
|
||||
cp shellAppDir, installDir
|
||||
if process.platform is 'win32'
|
||||
done = @async()
|
||||
|
||||
runas = require 'runas'
|
||||
copyFolder = path.resolve 'script', 'copy-folder.cmd'
|
||||
# cmd /c ""script" "source" "destination""
|
||||
arg = "/c \"\"#{copyFolder}\" \"#{shellAppDir}\" \"#{installDir}\"\""
|
||||
if runas('cmd', [arg], hide: true) isnt 0
|
||||
done("Failed to copy #{shellAppDir} to #{installDir}")
|
||||
|
||||
createShortcut = path.resolve 'script', 'create-shortcut.cmd'
|
||||
args = ['/c', createShortcut, path.join(installDir, 'atom.exe'), 'Atom']
|
||||
spawn {cmd: 'cmd', args}, done
|
||||
else
|
||||
rm installDir
|
||||
mkdir path.dirname(installDir)
|
||||
cp shellAppDir, installDir
|
||||
|
||||
18
script/copy-folder.cmd
Normal file
18
script/copy-folder.cmd
Normal file
@@ -0,0 +1,18 @@
|
||||
@echo off
|
||||
|
||||
set USAGE=Usage: %0 source destination
|
||||
|
||||
if [%1] == [] (
|
||||
echo %USAGE%
|
||||
exit 1
|
||||
)
|
||||
if [%2] == [] (
|
||||
echo %USAGE%
|
||||
exit 2
|
||||
)
|
||||
|
||||
:: rm -rf %2
|
||||
if exist %2 rmdir %2 /s /q
|
||||
|
||||
:: cp -rf %1 %2
|
||||
xcopy %1 %2 /e /h /c /i /y /r
|
||||
23
script/create-shortcut.cmd
Normal file
23
script/create-shortcut.cmd
Normal file
@@ -0,0 +1,23 @@
|
||||
@echo off
|
||||
|
||||
set USAGE=Usage: %0 source name-on-desktop
|
||||
|
||||
if [%1] == [] (
|
||||
echo %USAGE%
|
||||
exit 1
|
||||
)
|
||||
if [%2] == [] (
|
||||
echo %USAGE%
|
||||
exit 2
|
||||
)
|
||||
|
||||
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
|
||||
|
||||
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
|
||||
echo sLinkFile = "%USERPROFILE%\Desktop\%2.lnk" >> %SCRIPT%
|
||||
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
|
||||
echo oLink.TargetPath = %1 >> %SCRIPT%
|
||||
echo oLink.Save >> %SCRIPT%
|
||||
|
||||
cscript /nologo %SCRIPT%
|
||||
del %SCRIPT%
|
||||
@@ -15,7 +15,11 @@ url = require 'url'
|
||||
{EventEmitter} = require 'events'
|
||||
_ = require 'underscore-plus'
|
||||
|
||||
socketPath = path.join(os.tmpdir(), 'atom.sock')
|
||||
socketPath =
|
||||
if process.platform is 'win32'
|
||||
'\\\\.\\pipe\\atom-sock'
|
||||
else
|
||||
path.join(os.tmpdir(), 'atom.sock')
|
||||
|
||||
# Private: The application's singleton class.
|
||||
#
|
||||
@@ -35,7 +39,7 @@ class AtomApplication
|
||||
# take a few seconds to trigger 'error' event, it could be a bug of node
|
||||
# or atom-shell, before it's fixed we check the existence of socketPath to
|
||||
# speedup startup.
|
||||
if (not fs.existsSync socketPath) or options.test
|
||||
if (process.platform isnt 'win32' and not fs.existsSync socketPath) or options.test
|
||||
createAtomApplication()
|
||||
return
|
||||
|
||||
@@ -99,7 +103,8 @@ class AtomApplication
|
||||
# the other launches will just pass their information to this server and then
|
||||
# close immediately.
|
||||
listenForArgumentsFromNewProcess: ->
|
||||
fs.unlinkSync socketPath if fs.existsSync(socketPath)
|
||||
if process.platform isnt 'win32' and fs.existsSync(socketPath)
|
||||
fs.unlinkSync socketPath
|
||||
server = net.createServer (connection) =>
|
||||
connection.on 'data', (data) =>
|
||||
@openWithOptions(JSON.parse(data))
|
||||
@@ -152,7 +157,9 @@ class AtomApplication
|
||||
app.quit() if process.platform is 'win32'
|
||||
|
||||
app.on 'will-quit', =>
|
||||
fs.unlinkSync socketPath if fs.existsSync(socketPath) # Clean the socket file when quit normally.
|
||||
# Clean the socket file when quit normally.
|
||||
if process.platform isnt 'win32' and fs.existsSync(socketPath)
|
||||
fs.unlinkSync socketPath
|
||||
|
||||
app.on 'open-file', (event, pathToOpen) =>
|
||||
event.preventDefault()
|
||||
|
||||
Reference in New Issue
Block a user