mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Install atom executable during window.startup()
Previously this was done during `rake install`. Also default to `~/github/atom` as the default resource path when no `--resource-path` argument is specified. This argument will now be required when running in dev mode if the repository is not at the default location. Closes #300
This commit is contained in:
38
Rakefile
38
Rakefile
@@ -41,17 +41,6 @@ task :install => [:clean, :build] do
|
|||||||
`rm -rf #{dest}`
|
`rm -rf #{dest}`
|
||||||
`cp -r #{path} #{File.expand_path(dest)}`
|
`cp -r #{path} #{File.expand_path(dest)}`
|
||||||
|
|
||||||
# Install cli atom
|
|
||||||
usr_bin_path = "/opt/github/bin"
|
|
||||||
cli_path = "#{usr_bin_path}/atom"
|
|
||||||
|
|
||||||
template = ERB.new CLI_SCRIPT
|
|
||||||
namespace = OpenStruct.new(:application_path => dest, :resource_path => ATOM_SRC_PATH)
|
|
||||||
File.open(cli_path, "w") do |f|
|
|
||||||
f.write template.result(namespace.instance_eval { binding })
|
|
||||||
f.chmod(0755)
|
|
||||||
end
|
|
||||||
|
|
||||||
Rake::Task["clone-default-bundles"].invoke()
|
Rake::Task["clone-default-bundles"].invoke()
|
||||||
|
|
||||||
puts "\033[32mType `atom` to start Atom! In Atom press `cmd-,` to edit your `~/.atom` directory\033[0m"
|
puts "\033[32mType `atom` to start Atom! In Atom press `cmd-,` to edit your `~/.atom` directory\033[0m"
|
||||||
@@ -130,30 +119,3 @@ def application_path
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
CLI_SCRIPT = <<-EOF
|
|
||||||
#!/bin/sh
|
|
||||||
open -a Atom -n --args --resource-path="<%= resource_path %>" --executed-from="$(pwd)" --pid=$$ $@
|
|
||||||
|
|
||||||
# Used to exit process when atom is used as $EDITOR
|
|
||||||
on_die() {
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
trap 'on_die' SIGQUIT SIGTERM
|
|
||||||
|
|
||||||
# Don't exit process if we were told to wait.
|
|
||||||
while [ "$#" -gt "0" ]; do
|
|
||||||
case $1 in
|
|
||||||
-W|--wait)
|
|
||||||
WAIT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $WAIT ]; then
|
|
||||||
while true; do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
|
|||||||
24
atom.sh
Normal file
24
atom.sh
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
open -a Atom -n --args --executed-from="$(pwd)" --pid=$$ $@
|
||||||
|
|
||||||
|
# Used to exit process when atom is used as $EDITOR
|
||||||
|
on_die() {
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
trap 'on_die' SIGQUIT SIGTERM
|
||||||
|
|
||||||
|
# Don't exit process if we were told to wait.
|
||||||
|
while [ "$#" -gt "0" ]; do
|
||||||
|
case $1 in
|
||||||
|
-W|--wait)
|
||||||
|
WAIT=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $WAIT ]; then
|
||||||
|
while true; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
@@ -33,6 +33,17 @@
|
|||||||
AtomApplication *atomApplication = (AtomApplication *)[AtomApplication sharedApplication];
|
AtomApplication *atomApplication = (AtomApplication *)[AtomApplication sharedApplication];
|
||||||
|
|
||||||
_resourcePath = [atomApplication.arguments objectForKey:@"resource-path"];
|
_resourcePath = [atomApplication.arguments objectForKey:@"resource-path"];
|
||||||
|
if (!alwaysUseBundleResourcePath && !_resourcePath) {
|
||||||
|
NSString *defaultRepositoryPath = @"~/github/atom";
|
||||||
|
defaultRepositoryPath = [defaultRepositoryPath stringByStandardizingPath];
|
||||||
|
if ([defaultRepositoryPath characterAtIndex:0] == '/') {
|
||||||
|
BOOL isDir = false;
|
||||||
|
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:defaultRepositoryPath isDirectory:&isDir];
|
||||||
|
if (isDir && exists)
|
||||||
|
_resourcePath = defaultRepositoryPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (alwaysUseBundleResourcePath || !_resourcePath) {
|
if (alwaysUseBundleResourcePath || !_resourcePath) {
|
||||||
_resourcePath = [[NSBundle mainBundle] resourcePath];
|
_resourcePath = [[NSBundle mainBundle] resourcePath];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,4 +38,4 @@ for CSON_FILE in $CSON_FILES; do
|
|||||||
done;
|
done;
|
||||||
|
|
||||||
# Copy non-coffee files into bundle
|
# Copy non-coffee files into bundle
|
||||||
rsync --archive --recursive --exclude="src/**/*.coffee" --exclude="src/**/*.cson" src static vendor spec benchmark themes dot-atom "$RESOUCES_PATH"
|
rsync --archive --recursive --exclude="src/**/*.coffee" --exclude="src/**/*.cson" src static vendor spec benchmark themes dot-atom atom.sh "$RESOUCES_PATH"
|
||||||
|
|||||||
@@ -116,3 +116,16 @@ describe "Window", ->
|
|||||||
window.shutdown()
|
window.shutdown()
|
||||||
window.shutdown()
|
window.shutdown()
|
||||||
expect(atom.setRootViewStateForPath.callCount).toBe 1
|
expect(atom.setRootViewStateForPath.callCount).toBe 1
|
||||||
|
|
||||||
|
describe ".installAtomCommand(commandPath)", ->
|
||||||
|
commandPath = '/tmp/installed-atom-command/atom'
|
||||||
|
|
||||||
|
afterEach ->
|
||||||
|
fs.remove(commandPath) if fs.exists(commandPath)
|
||||||
|
|
||||||
|
describe "when the command path doesn't exist", ->
|
||||||
|
it "copies atom.sh to the specified path", ->
|
||||||
|
expect(fs.exists(commandPath)).toBeFalsy()
|
||||||
|
window.installAtomCommand(commandPath)
|
||||||
|
expect(fs.exists(commandPath)).toBeTruthy()
|
||||||
|
expect(fs.read(commandPath).length).toBeGreaterThan 1
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
fs = require 'fs'
|
fs = require 'fs'
|
||||||
$ = require 'jquery'
|
$ = require 'jquery'
|
||||||
|
ChildProcess = require 'child-process'
|
||||||
require 'jquery-extensions'
|
require 'jquery-extensions'
|
||||||
require 'underscore-extensions'
|
require 'underscore-extensions'
|
||||||
require 'space-pen-extensions'
|
require 'space-pen-extensions'
|
||||||
@@ -39,6 +40,7 @@ window.setUpEnvironment = ->
|
|||||||
|
|
||||||
# This method is only called when opening a real application window
|
# This method is only called when opening a real application window
|
||||||
window.startup = ->
|
window.startup = ->
|
||||||
|
installAtomCommand('/opt/github/bin/atom')
|
||||||
handleWindowEvents()
|
handleWindowEvents()
|
||||||
config.load()
|
config.load()
|
||||||
atom.loadTextPackage()
|
atom.loadTextPackage()
|
||||||
@@ -65,6 +67,14 @@ window.shutdown = ->
|
|||||||
window.rootView = null
|
window.rootView = null
|
||||||
window.project = null
|
window.project = null
|
||||||
|
|
||||||
|
window.installAtomCommand = (commandPath) ->
|
||||||
|
return if fs.exists(commandPath)
|
||||||
|
|
||||||
|
bundledCommandPath = fs.resolve(window.resourcePath, 'atom.sh')
|
||||||
|
if bundledCommandPath?
|
||||||
|
fs.write(commandPath, fs.read(bundledCommandPath))
|
||||||
|
ChildProcess.exec("chmod u+x '#{commandPath}'")
|
||||||
|
|
||||||
window.handleWindowEvents = ->
|
window.handleWindowEvents = ->
|
||||||
$(window).on 'core:close', => window.close()
|
$(window).on 'core:close', => window.close()
|
||||||
$(window).command 'window:close', => window.close()
|
$(window).command 'window:close', => window.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user