summaryrefslogtreecommitdiff
path: root/app-editors/atom/files/transpile-coffee-script.js
blob: bbea175b6721049197855432d5d9f899336dca24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict'

const CompileCache = require(process.env.ATOM_SRC_ROOT + '/src/compile-cache')
const fs = require('fs')
const glob = require('glob')
const path = require('path')

function do_compile() {
  let paths = new Set()

  for (let pattern of process.argv.slice(2)) {
    for (let path of glob.sync(pattern, {nodir: true})) {
      paths.add(path)
    }
  }

  for (let coffeePath of paths) {
    let jsPath = coffeePath.replace(/coffee$/g, 'js')
    fs.writeFileSync(
      jsPath, CompileCache.addPathToCache(coffeePath, process.env.ATOM_HOME))
    fs.unlinkSync(coffeePath)
  }
}

do_compile()