Skip to content

Instantly share code, notes, and snippets.

@hideokamoto
Created April 15, 2015 05:19
Show Gist options
  • Save hideokamoto/7055ee43e0ff40997a94 to your computer and use it in GitHub Desktop.
Save hideokamoto/7055ee43e0ff40997a94 to your computer and use it in GitHub Desktop.
ymlファイルが更新されたら勝手にDBを更新する
//node.jsのchild-processを呼び出す
var exec = require('child_process').exec;
//ymlファイルの更新を監視する
gulp.task('default',function(){
gulp.watch("orm/yaml/**.yml",['db-update']);
});
//DoctrineでEntityを作る
gulp.task('db-generate-entities', function(){
return exec('doctrine orm:generate-entities app/orm',
function (error, stdout, stderr) {
console.log('generate');
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
});
//DoctrineでDBをアップデートする
gulp.task('db-update', ['db-generate-entities'], function(){
return exec('doctrine orm:schema-tool:update --force',
function (error, stdout, stderr) {
console.log('update');
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment