Coffeescript basic compiling error - coffeescript

Just getting started with Coffeescript and have installed it correctly , however having problems getting basic compilation to work
I have 2 folders names 'src' and 'js'
I create a simple .coffee file in the src folder called test.coffee
In the parent folder I open a terminal window and type the following
coffee -wc src -o js
This SHOULD automatically compile any .coffee files in the src folder and put in the js folder but I always get an error
File not found: –wc.coffee
What am I doing wrong?

Coffee is picky about parameter order.
Usage: coffee [options] path/to/script.coffee -- [args]
As you see, you have to specify all options before the script (or directory) you want to compile:
coffee -w -c -o js src
or
coffee -wco js src

According to the usage examples on coffeescript.org, the "watch" functionality is for files, not directories.
Try dropping the -w.

Related

BabelJS: Doesn't find all .js files in directory

Babel doesn't find all of my .js/.es6 files in my directory.
I have this directory structure:
src/
assets/
sample/
models.es6
scripts/
playground.es6
If I run babel src --out-dir dist --source-maps --copy-files --presets env, it only transpiles /src/assets/sample/models.es6 and doesnt go through src/scripts/playground.es6.
What am I doing wrong?
Looking forward to your response!
You can do like below :
babel src/** --out-dir lib
more at official doc
Compile Directories
Compile the entire src directory and output it to the lib directory. You may use --out-dir or -d. This doesn’t overwrite any other files or directories in lib.
if you still stuck, you can use gulp or grunt or webpack to load/transpile mupltiple directives from different locations.
Hope it helps
I found the problem. It has barely to do with Babel.
Inside the src/assets/** is my Realm database sample.realm (https://realm.io). The file itself doesnt cause the problem. But if you open the sample.realm file with Realm Studio on MacOSX, a file called sample.realm.note gets created. This file causes babel to not exit the transpile task.

WebStorm's 'CoffeeScript Source Map' File Watcher generates an error

I am trying to get chrome to use source maps so I can walk through my coffeescript not the transpiled javascript.
Using WebStorm 7, I have added a CoffeeScript Source Map File Watcher, like so:
Now whenever I make a change to a coffeescript file I see the following error:
Can you tell me the correct way to generate source maps for my coffeescript files so I can step through the coffeescript rather than the transpiled javascript.
Thanks
please remove the second watcher (CoffeeScript Source map) and edit the first one as follows:
Program: C:\Users\janderson\AppData\Roaming\npm\coffee.cmd
Arguments: --compile --map $FileName$
Working directory: $FileDir$
Output paths to refresh: $FileNameWithoutExtension$.js:$FileNameWithoutExtension$.map

CoffeeScript Compile On Windows With NodeJS

I have installed nodejs, installed coffee using npm and registered the environment variables and am now ready to compile my CoffeeScript into JavaScript for the first time.
I am running the following command in c:\MyCoffeeScriptProject\
coffee --compile --output js/
What happens next is that I get the interactive window and nothing in the "js" folder.
coffee>
I was expecting all .coffee files to be compiled into the "js" folder as .js files.
You didn't tell it which files to compile.
Usage: coffee [options] path/to/script.coffee [args]
Append a single period to the end for the current directory.
coffee --compile --output js/ .
It's easier to read if you rearrange it though.
coffee --output js/ --compile .
compiles all coffee files in . to js/
A common usage pattern is to have a src folder.
coffee --output js/ --compile src/
c:/parent>coffee --output output --compile src
Where "output" is blank folder and "src" folder contains coffee files.
Execute the command at level of src.

CoffeeScript - compile all .coffee files in current directory and all sub-directories

What is the easiest way to compile all .coffee files in the current directory and all sub-directories?
you can do so with the integrated coffee shell tool:
coffee --output lib --compile src
compiles a directory tree of .coffee files in src into a parallel tree of .js files in lib.
Check http://coffeescript.org/#usage for more details
coffee -c .
Thanks #TrevorBurnham
coffee --watch --compile .
or
coffee -wc .
Either of these commands will run forever, watching for *.coffee files in the current directory, and compiling those *.coffee files into *.js JavaScript files whenever the *.coffee files are changed.
If you want the *.js files to be generated into some other directory, just add --output or -o, like this:
coffee --watch --output lib --compile src
or
coffee -w -o lib -c src
If you are using *nix systems:
find -name "*.coffee" -exec coffee -c {} \;
and you may also consider using Guard: https://github.com/guard/guard-coffeescript

How to watch and recompile coffee scripts as they change?

Some time ago I used to do
coffee --bare --output . --watch --compile .
This watches the .coffee files in the current dir and recompiles them as they change.
Now, using 1.2.0 of coffeescript this does not seem to work any more. I'm presented with an error:
File not found: --watch.coffee
and the usage documentation for coffee seems rather light.
I'd skip the --output ., as it seems to be unnecessary if you're already in the same directory, and go straight with
coffee -bcw *.coffee
Otherwise, this is a duplicate of Compile CoffeeScript on Save?
BTW, you can also go:
coffee -bcw .
which will not only save a few keystrokes, but also scan subdirectories to compile .coffee files.