]> khamidou — GitHub mirrors - electron.git/commitdiff
Write js codes in coffee script.
authorCheng Zhao <zcbenz@gmail.com>
Sun, 14 Apr 2013 14:48:35 +0000 (22:48 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 14 Apr 2013 14:48:35 +0000 (22:48 +0800)
.gitignore
atom.gyp
browser/atom/atom.coffee [new file with mode: 0644]
browser/atom/atom.js [deleted file]
package.json [new file with mode: 0644]
script/bootstrap
script/compile-coffee [new file with mode: 0755]

index 52c9b42256a6758ccecf4abf3c33c0c4df5bc191..be7d595986d2770f91152580f766aba2be1d8348 100644 (file)
@@ -1,4 +1,5 @@
 .DS_Store
 build/
+node_modules/
 *.xcodeproj
 *.swp
index ac5052db125b025b7a6fdf8e1d9690152ea24460..561a11fd8a9dae121ae2a59293ac2281eeac1614 100644 (file)
--- 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': [
                 '<(PRODUCT_DIR)/<(product_name).framework',
               ],
             },
-            {
-              'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
-              'files': [
-                'browser/atom',
-              ],
-            },
           ],
           'postbuilds': [
             {
         '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 (file)
index 0000000..e6744db
--- /dev/null
@@ -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 (file)
index c870861..0000000
+++ /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 (file)
index 0000000..8606627
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "name"    : "atom",
+  "version" : "0.1.0",
+
+  "dependencies": {
+    "coffee-script": "1.6.2"
+  },
+
+  "private": true,
+
+  "scripts": {
+    "preinstall": "true"
+  }
+}
index dd77b1a4331353bbf76799bf846daa1eecba6ba6..0352ee2a4124e084105812fe8177414c9a431d05 100755 (executable)
@@ -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 (executable)
index 0000000..2c15358
--- /dev/null
@@ -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"