Skip to content

Commit

Permalink
Merge branch 'master' into v0.24-rc
Browse files Browse the repository at this point in the history
Conflicts:
	tools/buildBabel.js
  • Loading branch information
mtscout6 committed Jun 13, 2015
2 parents 36358d6 + 6bcddb7 commit 6e60d2b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tools/buildBabel.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import { transform } from 'babel-core';
import resolveRc from 'babel-core/lib/babel/tools/resolve-rc';
import * as babelUtil from 'babel-core/lib/babel/util';
import glob from 'glob';
import fs from 'fs';
import path from 'path';
import outputFileSync from 'output-file-sync';

export function buildContent(content, filename, destination, babelOptions={}) {
const result = transform(content, resolveRc(filename, babelOptions));
babelOptions.filename = filename;
const result = transform(content, babelOptions);
outputFileSync(destination, result.code, {encoding: 'utf8'});
}

export function buildFile(filename, destination, babelOptions={}) {
const content = fs.readFileSync(filename, {encoding: 'utf8'});
if(babelUtil.canCompile(filename)) {
// Get file basename without the extension (in case not .js)
let outputName = path.basename(filename, path.extname(filename));
// append the file basename with extension .js
let outputPath = path.join(destination, outputName + '.js');
// We only have .js files that we need to build
if(path.extname(filename) === '.js') {
const outputPath = path.join(destination, path.basename(filename));
// console.log('%s => %s', filename, outputPath);
buildContent(content, filename, outputPath, babelOptions);
}
Expand Down

0 comments on commit 6e60d2b

Please sign in to comment.