Skip to content

Instantly share code, notes, and snippets.

@denchistyakov
Created December 18, 2013 07:21
Show Gist options
  • Save denchistyakov/8018550 to your computer and use it in GitHub Desktop.
Save denchistyakov/8018550 to your computer and use it in GitHub Desktop.
'use strict';
module.exports = function (grunt) {
grunt.registerTask('dev', 'setup development enviroment', function() {
require('shelljs/global');
groupCheck();
rootDir();
serverDir();
staticDir();
echo('Site should be available at http://{PROJECTNAME}.$(USER).nodejs.dev.spec.yandex.ru/');
function groupCheck() {
var id = ~~exec('id -u', {silent:true}).output.trim(),
groups = exec('groups | grep -o "www-data"', {silent:true}).output.trim();
if (id !== 0 && groups === '') {
echo('You must be in www-data group to run "make dev" (or root)');
echo('To add yourself in www-data type:');
echo('sudo usermod -a -G www-data $USER');
echo('After that logout and login. You should see www-data in output of "groups" command');
exit(1);
}
}
function rootDir() {
exec('npm install --registry=http://npm.yandex-team.ru');
}
function serverDir() {
cd('server');
exec('npm install --registry=http://npm.yandex-team.ru');
cd('..');
}
function staticDir() {
cd('static');
exec('npm install --registry=http://npm.yandex-team.ru');
exec('./node_modules/.bin/bower install --allow-root');
exec('./node_modules/.bin/enb make');
cd('..');
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment