Use administrator power to install Atom on Windows.

This commit is contained in:
Cheng Zhao
2014-01-24 21:07:32 +08:00
parent c5d7614d80
commit b1778aa7df
3 changed files with 30 additions and 3 deletions

View File

@@ -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"

View File

@@ -6,6 +6,14 @@ module.exports = (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'
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
throw new Error("Failed to copy #{shellAppDir} to #{installDir}")
else
rm installDir
mkdir path.dirname(installDir)
cp shellAppDir, installDir

18
script/copy-folder.cmd Normal file
View 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