0

Here is my compile.sh:

#!/bin/bash
coffee -o public/app/ -cwb public/src/

When i open script by double click:

File not found: public/src/.coffee

It is work only from terminal: ./compile.sh

May be there is best way to compile CoffeScript on Mac OS X?

3 Answers 3

5

If you are trying to get a coffeescript "script" to execute by "running it", similar to other scripts in a unix environment, you could try something like the following in your script, and make sure to set it to executable (chmod a+x scriptname.coffee):

#!/usr/bin/env coffee
path = require 'path'
fs = require 'fs'
...

At least that is how I launch executable coffeescript "scripts" at my end (a Linux system, but still...).

Sign up to request clarification or add additional context in comments.

3 Comments

Don't work. I need script to run same comand from terminal: coffee -o "public/app/" -cwb "public/src/"
I see, so you need to actually run the compile process when clicking, not run a compiled script itself. Sandro's answer is probably what you are looking for, but you may also want to consider the "watch" which allows the compiler to detect and compile changed scripts on demand.
This may not have been the subject of the original question, but it helped me creating a shell script using coffeescript. Thanks for that ;)
1

Choroba is correct.

But instead of using full directory paths you could also get the current directory programmatically so you don't have to hard code any paths.

#!/bin/bash
DIR="$( cd "$( dirname "$0" )" && pwd )"
coffee -o $DIR/public/app/ -cwb $DIR/public/src/

Comments

0

When clicked, the script probably starts in a different folder. Use full paths in your script to make it universal.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.