How to use coffee-script - 10 common examples

To help you get started, we’ve selected a few coffee-script examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jimdo / angular-draggabilly / test / e2e / env / config.js View on Github external
var browsers = process.env.PROTRACTOR_BROWSERS;
var reporter = process.env.PROTRACTOR_REPORTERS;
var capabilities = [];
(browsers || 'chrome').split(',').forEach(function(browser) {
  capabilities.push({browserName: browser.toLowerCase()});
});

/* Add coffeescript support */
require('coffee-script').register();

/* See tasks/options/protractor.js for config */
/* We still need to set some config thats not supported by grunt-protractor-runner */
exports.config = {
  multiCapabilities: capabilities,
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 360000,
    silent: !!reporter
  },
  onPrepare: function() {
    switch(reporter) {
      case 'spec':
        var SpecReporter = require('jasmine-spec-reporter');
        jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: true}));
        break;
github jonschlinkert / gray-matter / test / parse-coffee.js View on Github external
parse: function(str, options) {
        /* eslint no-eval: 0 */
        return coffee['eval'](str, options);
      }
    }
github jonschlinkert / gray-matter / test / parse-cson.js View on Github external
parse: function(str, options) {
        /* eslint no-eval: 0 */
        return coffee['eval'](str, options);
      }
    }
github peerplays-network / peerplays-core-gui / src / __tests__ / __tests__ / jest-preprocessor.js View on Github external
process: function(src, path) {
    src = babel_jest.process(src, path)
    // CoffeeScript files can be .coffee, .litcoffee, or .coffee.md
    if (coffee.helpers.isCoffee(path)) {
      return coffee.compile(src, {'bare': true});
    }
    return src;
  }
}
github fishbar / jscoverage / lib / patch.js View on Github external
Module._extensions['.coffee'] = Module._extensions['.litcoffee'] = function (module, filename, status) {
      var CoffeeScript = require('coffee-script');
      var content = CoffeeScript._compileFile(filename, false);
      var tmpFuncBody;
      var injectFn = exports.getInjectFunctions();
      // trim first line when script is a shell script
      // content = content.replace(/^\#\![^\n]+\n/, '');
      if (status && status.flagjsc) {
        content = jscoverage.process(filename, content);
      }
      if (status && status.needinject) {
        tmpFuncBody = injectFunctionBody.toString().replace(/\$\$(\w+)\$\$/g, function (m0, m1) {
          return injectFunctions[m1];
        });
        tmpFuncBody = tmpFuncBody.split(/\n/);
        content += '\n' + tmpFuncBody.slice(1, tmpFuncBody.length - 1).join('\n');
      }
      module._compile(stripBOM(content), filename);
    };
github SimonDegraeve / cjsxify / index.js View on Github external
function compile(file, data, callback) {
    var compiled;
    try {
        compiled = coffee.compile(cjsx(data), { // compile cjsx to coffee, then coffee to js
            sourceMap: true,
            generatedFile: file,
            inline: true,
            bare: true,
            literate: false
        });
    } catch (e) {
        var error = e;
        if (e.location) {
            error = new ParseError(e, data, file);
        }
        callback(error);
        return;
    }

    var map = convert.fromJSON(compiled.v3SourceMap);
github rlidwka / node-hotswap / hotswap.js View on Github external
function extension_js(type, module, filename)
{
	var is_hotswap_file = false;
	var content = get_file_contents(filename);
	delete fscache[filename];
	var iscompiled = false;
	
	fs.stat(filename, function(err, stats) {
		hotswap[filename] = stats.mtime;
	});

	if (type == 'coffee') {
		var compiled = require('coffee-script').compile(content, {
			filename: filename
		});
		module._compile(compiled, filename);
	} else {
		module._compile(content, filename);
	}

	var oldmodule = loaded_mods[filename];
	var newmodule = require.cache[filename];
	// require('repl').start() resets require.cache?
	if (typeof(newmodule) !== 'object') return;

	is_hotswap_file = !!newmodule.change_code;
	if (!is_hotswap_file) return;

	if (typeof(newmodule.exports) != 'object' && typeof(newmodule.exports) != 'function') {
github power-assert-js / espower-coffee / index.js View on Github external
if (! minimatch(filepath, pattern)) {
            return originalCompileFile(filepath, sourceMap);
        }
        var withMap = originalCompileFile(filepath, true); // enable sourcemaps
        var conv = convert.fromJSON(withMap.v3SourceMap);
        // restore filepath since coffeescript compiler drops it
        conv.setProperty('sources', [filepath]);
        withMap.js = espowerSource(
            withMap.js,
            filepath,
            extend(options.espowerOptions, { sourceMap: conv.toObject(), sourceRoot: options.cwd })
        );
        return sourceMap ? withMap : withMap.js;
    };

    coffee.register();
}
github nylas-mail-lives / nylas-mail / static / index.js View on Github external
function registerRuntimeTranspilers() {
  // This sets require.extensions['.coffee'].
  require('coffee-script').register();
  require('coffee-react/register');

  // This redefines require.extensions['.js'].
  require('../src/6to5').register();
}
github fossasia / susper.com / node_modules / protractor / built / configParser.js View on Github external
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const glob = require("glob");
const path = require("path");
const exitCodes_1 = require("./exitCodes");
const logger_1 = require("./logger");
let logger = new logger_1.Logger('configParser');
// Coffee is required here to enable config files written in coffee-script.
try {
    require('coffee-script').register();
}
catch (e) {
    // Intentionally blank - ignore if coffee-script is not available.
}
// CoffeeScript lost the hyphen in the module name a long time ago, all new version are named this:
try {
    require('coffeescript').register();
}
catch (e) {
    // Intentionally blank - ignore if coffeescript is not available.
}
// LiveScript is required here to enable config files written in LiveScript.
try {
    require('LiveScript');
}
catch (e) {