Skip to content

Fix relative path replacement in bin/dev. #542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ var nodemon = require('nodemon');
var babel = require("babel-core");
var gaze = require('gaze');
var fs = require('fs');
var path = require('path');

// Watch the src and transpile when changed
gaze('src/**/*', function(err, watcher) {
if (err) throw err;
watcher.on('changed', function(file) {
console.log(file + " has changed");
watcher.on('changed', function(sourceFile) {
console.log(sourceFile + " has changed");
try {
fs.writeFile(file.replace(/\/src\//, "/lib/"), babel.transformFileSync(file).code);
targetFile = path.relative(__dirname, sourceFile).replace(/\/src\//, '/lib/');
targetFile = path.resolve(__dirname, targetFile);
fs.writeFile(targetFile, babel.transformFileSync(sourceFile).code);
} catch (e) {
console.error(e.message, e.stack);
}
Expand Down