diff --git a/.gitignore b/.gitignore index 52c9b42256a6..be7d595986d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store build/ +node_modules/ *.xcodeproj *.swp diff --git a/atom.gyp b/atom.gyp index ac5052db125b..561a11fd8a9d 100644 --- a/atom.gyp +++ b/atom.gyp @@ -5,6 +5,9 @@ 'app_sources': [ 'app/atom_main.cc', ], + 'coffee_sources': [ + 'browser/atom/atom.coffee', + ], 'lib_sources': [ 'app/atom_main_delegate.cc', 'app/atom_main_delegate.h', @@ -48,6 +51,7 @@ 'target_name': '<(project_name)', 'type': 'executable', 'dependencies': [ + 'generated_sources', '<(project_name)_lib', ], 'sources': [ @@ -79,12 +83,6 @@ '<(PRODUCT_DIR)/<(product_name).framework', ], }, - { - 'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources', - 'files': [ - 'browser/atom', - ], - }, ], 'postbuilds': [ { @@ -122,6 +120,31 @@ 'vendor', ], }, + { + 'target_name': 'generated_sources', + 'type': 'none', + 'sources': [ + '<@(coffee_sources)', + ], + 'rules': [ + { + 'rule_name': 'coffee', + 'extension': 'coffee', + 'inputs': [ + 'script/compile-coffee', + ], + 'outputs': [ + '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js', + ], + 'action': [ + 'sh', + 'script/compile-coffee', + '<(RULE_INPUT_PATH)', + '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js', + ], + }, + ], + }, ], 'conditions': [ ['OS=="mac"', { diff --git a/browser/atom/atom.coffee b/browser/atom/atom.coffee new file mode 100644 index 000000000000..e6744db1325a --- /dev/null +++ b/browser/atom/atom.coffee @@ -0,0 +1,7 @@ +# Don't quit on fatal error. +process.on "uncaughtException", (error) -> + console.error "uncaughtException:" + if error.stack? + console.error error.stack + else + console.error error.name + ": " + error.message diff --git a/browser/atom/atom.js b/browser/atom/atom.js deleted file mode 100644 index c87086139660..000000000000 --- a/browser/atom/atom.js +++ /dev/null @@ -1,9 +0,0 @@ -process.on('uncaughtException', function(error) { - console.error('uncaughtException:'); - if (error.stack) - console.error(error.stack); - else - console.error(error.name + ': ' + error.message); -}); - -console.log(process.atom_binding('window')); diff --git a/package.json b/package.json new file mode 100644 index 000000000000..8606627711c0 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name" : "atom", + "version" : "0.1.0", + + "dependencies": { + "coffee-script": "1.6.2" + }, + + "private": true, + + "scripts": { + "preinstall": "true" + } +} diff --git a/script/bootstrap b/script/bootstrap index dd77b1a43313..0352ee2a4124 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -23,6 +23,9 @@ BRIGHTRAY_DIR="${VENDOR_DIR}/brightray" git submodule sync --quiet git submodule update --init --recursive +npm install npm --silent +./node_modules/.bin/npm install --silent + "${BRIGHTRAY_DIR}/script/bootstrap" "${BASE_URL}" "${SOURCE_ROOT}/script/update" diff --git a/script/compile-coffee b/script/compile-coffee new file mode 100755 index 000000000000..2c15358c9d78 --- /dev/null +++ b/script/compile-coffee @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +# Because of the way xcodebuild invokes external scripts we need to load +# The Setup's environment ourselves. If this isn't done, things like the +# node shim won't be able to find the stuff they need. + +node --version > /dev/null 2>&1 || { + if [ -e /opt/github/env.sh ]; then + source /opt/github/env.sh + else + # Try Constructicon's PATH. + export PATH="/usr/local/Cellar/node/0.8.21/bin:${PATH}" + fi +} + +INPUT_FILE="${1}" +OUTPUT_DIR=`dirname "$2"` + +node_modules/.bin/coffee -c -o "$OUTPUT_DIR" "$INPUT_FILE"