Write js codes in coffee script.

This commit is contained in:
Cheng Zhao 2013-04-14 22:48:35 +08:00
parent ad708fdfbd
commit ee420b1590
7 changed files with 75 additions and 15 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
.DS_Store .DS_Store
build/ build/
node_modules/
*.xcodeproj *.xcodeproj
*.swp *.swp

View file

@ -5,6 +5,9 @@
'app_sources': [ 'app_sources': [
'app/atom_main.cc', 'app/atom_main.cc',
], ],
'coffee_sources': [
'browser/atom/atom.coffee',
],
'lib_sources': [ 'lib_sources': [
'app/atom_main_delegate.cc', 'app/atom_main_delegate.cc',
'app/atom_main_delegate.h', 'app/atom_main_delegate.h',
@ -48,6 +51,7 @@
'target_name': '<(project_name)', 'target_name': '<(project_name)',
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'generated_sources',
'<(project_name)_lib', '<(project_name)_lib',
], ],
'sources': [ 'sources': [
@ -79,12 +83,6 @@
'<(PRODUCT_DIR)/<(product_name).framework', '<(PRODUCT_DIR)/<(product_name).framework',
], ],
}, },
{
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
'files': [
'browser/atom',
],
},
], ],
'postbuilds': [ 'postbuilds': [
{ {
@ -122,6 +120,31 @@
'vendor', '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': [ 'conditions': [
['OS=="mac"', { ['OS=="mac"', {

7
browser/atom/atom.coffee Normal file
View file

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

View file

@ -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'));

14
package.json Normal file
View file

@ -0,0 +1,14 @@
{
"name" : "atom",
"version" : "0.1.0",
"dependencies": {
"coffee-script": "1.6.2"
},
"private": true,
"scripts": {
"preinstall": "true"
}
}

View file

@ -23,6 +23,9 @@ BRIGHTRAY_DIR="${VENDOR_DIR}/brightray"
git submodule sync --quiet git submodule sync --quiet
git submodule update --init --recursive git submodule update --init --recursive
npm install npm --silent
./node_modules/.bin/npm install --silent
"${BRIGHTRAY_DIR}/script/bootstrap" "${BASE_URL}" "${BRIGHTRAY_DIR}/script/bootstrap" "${BASE_URL}"
"${SOURCE_ROOT}/script/update" "${SOURCE_ROOT}/script/update"

21
script/compile-coffee Executable file
View file

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