more progress

This commit is contained in:
Nathan Sobo
2016-03-23 19:43:32 -06:00
parent fb2f4fc5a4
commit e8392bd713
4 changed files with 13 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ const transpileBabelPaths = require('./lib/transpile-babel-paths')
const transpileCoffeeScriptPaths = require('./lib/transpile-coffee-script-paths')
function transpile () {
// transpileBabelPaths()
transpileBabelPaths()
transpileCoffeeScriptPaths()
}

View File

@@ -10,13 +10,14 @@ const appMetadata = require('../package.json')
const repositoryRootPath = path.resolve(__dirname, '..')
const buildOutputPath = path.join(repositoryRootPath, 'out')
const appName = appMetadata.productName
let appName = appMetadata.productName
const appFileName = appMetadata.name
let electronRootPath, electronAppPath
switch (process.platform) {
case 'darwin':
appName += '.app'
electronRootPath = path.join(buildOutputPath, appName, 'Contents')
electronAppPath = path.join(electronRootPath, 'Resources', 'app')
break;

View File

@@ -24,6 +24,7 @@ const PREFIX_LENGTH = Math.max.apply(null, BABEL_PREFIXES.map(prefix => prefix.l
const BUFFER = Buffer(PREFIX_LENGTH)
function transpileBabelPaths () {
console.log('Transpiling Babel paths...');
for (let srcPath of glob.sync(`${CONFIG.repositoryRootPath}/src/**/*.js`)) {
if (usesBabel(srcPath)) {
transpileBabelPath(srcPath, computeDestinationPath(srcPath))

View File

@@ -3,7 +3,10 @@
'use strict'
const coffee = require('coffee-script')
const fs = require('fs')
const glob = require('glob')
const mkdirp = require('mkdirp')
const path = require('path')
const CONFIG = require('../config')
@@ -18,8 +21,9 @@ const GLOBS = [
module.exports =
function transpileCoffeeScriptPaths () {
console.log('Transpiling CoffeeScript paths...');
for (let srcPath of getPathsToTranspile()) {
transpileCoffeeScriptPath(srcPath, computeDestinationPath(srcPath))
transpileCoffeeScriptPath(srcPath, computeDestinationPath(srcPath).replace(/coffee$/, 'js'))
}
}
@@ -32,5 +36,8 @@ function getPathsToTranspile () {
}
function transpileCoffeeScriptPath (srcPath, destPath) {
console.log(srcPath);
const inputCode = fs.readFileSync(srcPath, 'utf8')
let outputCode = coffee.compile(inputCode)
mkdirp.sync(path.dirname(destPath))
fs.writeFileSync(destPath, outputCode)
}