mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
WIP: Start on coffee transpilation
This commit is contained in:
parent
ff9b0af780
commit
fb2f4fc5a4
@ -3,9 +3,11 @@
|
||||
'use strict'
|
||||
|
||||
const transpileBabelPaths = require('./lib/transpile-babel-paths')
|
||||
const transpileCoffeeScriptPaths = require('./lib/transpile-coffee-script-paths')
|
||||
|
||||
function transpile () {
|
||||
transpileBabelPaths()
|
||||
// transpileBabelPaths()
|
||||
transpileCoffeeScriptPaths()
|
||||
}
|
||||
|
||||
transpile()
|
||||
|
13
build/lib/compute-destination-path.js
Normal file
13
build/lib/compute-destination-path.js
Normal file
@ -0,0 +1,13 @@
|
||||
// Takes an absolute path, relativizes it based on the repository root, then
|
||||
// makes it absolute again in the output app path.
|
||||
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const CONFIG = require('../config')
|
||||
|
||||
module.exports =
|
||||
function computeDestinationPath (srcPath) {
|
||||
let relativePath = path.relative(CONFIG.repositoryRootPath, srcPath)
|
||||
return path.join(CONFIG.electronAppPath, relativePath)
|
||||
}
|
@ -10,7 +10,9 @@ const fs = require('fs')
|
||||
const glob = require('glob')
|
||||
const mkdirp = require('mkdirp')
|
||||
const path = require('path')
|
||||
const computeDestinationPath = require('./compute-destination-path')
|
||||
|
||||
const CONFIG = require('../config')
|
||||
const BABEL_OPTIONS = require('../../static/babelrc.json')
|
||||
const BABEL_PREFIXES = [
|
||||
"'use babel'",
|
||||
@ -21,14 +23,10 @@ const BABEL_PREFIXES = [
|
||||
const PREFIX_LENGTH = Math.max.apply(null, BABEL_PREFIXES.map(prefix => prefix.length))
|
||||
const BUFFER = Buffer(PREFIX_LENGTH)
|
||||
|
||||
const CONFIG = require('../config')
|
||||
|
||||
function transpileBabelPaths () {
|
||||
for (let srcPath of glob.sync(`${__dirname}/../../src/**/*.js`)) {
|
||||
for (let srcPath of glob.sync(`${CONFIG.repositoryRootPath}/src/**/*.js`)) {
|
||||
if (usesBabel(srcPath)) {
|
||||
const relPath = path.relative(CONFIG.repositoryRootPath, srcPath)
|
||||
const destPath = path.join(CONFIG.electronAppPath, relPath)
|
||||
transpileBabelPath(srcPath, destPath)
|
||||
transpileBabelPath(srcPath, computeDestinationPath(srcPath))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
36
build/lib/transpile-coffee-script-paths.js
Normal file
36
build/lib/transpile-coffee-script-paths.js
Normal file
@ -0,0 +1,36 @@
|
||||
// This module exports a function that transpiles all .coffee files into the
|
||||
// appropriate location in the build output directory.
|
||||
|
||||
'use strict'
|
||||
|
||||
const glob = require('glob')
|
||||
const path = require('path')
|
||||
|
||||
const CONFIG = require('../config')
|
||||
const computeDestinationPath = require('./compute-destination-path')
|
||||
|
||||
const GLOBS = [
|
||||
'src/**/*.coffee,spec/*.coffee',
|
||||
'!spec/*-spec.coffee',
|
||||
'exports/**/*.coffee',
|
||||
'static/**/*.coffee'
|
||||
]
|
||||
|
||||
module.exports =
|
||||
function transpileCoffeeScriptPaths () {
|
||||
for (let srcPath of getPathsToTranspile()) {
|
||||
transpileCoffeeScriptPath(srcPath, computeDestinationPath(srcPath))
|
||||
}
|
||||
}
|
||||
|
||||
function getPathsToTranspile () {
|
||||
let paths = []
|
||||
paths = paths.concat(glob.sync(`${CONFIG.repositoryRootPath}/src/**/*.coffee`))
|
||||
paths = paths.concat(glob.sync(`${CONFIG.repositoryRootPath}/spec/*.coffee`, {ignore: '**/*-spec.coffee'}))
|
||||
paths = paths.concat(glob.sync(`${CONFIG.repositoryRootPath}/exports/**/*.coffee`))
|
||||
return paths
|
||||
}
|
||||
|
||||
function transpileCoffeeScriptPath (srcPath, destPath) {
|
||||
console.log(srcPath);
|
||||
}
|
Loading…
Reference in New Issue
Block a user