From aecd40324851a15719f0c477fafca318e75c2334 Mon Sep 17 00:00:00 2001 From: Sercan Date: Tue, 1 Mar 2016 22:21:09 +0200 Subject: [PATCH] added chimp dependent script --- .scripts/cache-velocity.js | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .scripts/cache-velocity.js diff --git a/.scripts/cache-velocity.js b/.scripts/cache-velocity.js new file mode 100644 index 0000000..7bf6809 --- /dev/null +++ b/.scripts/cache-velocity.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node +var path = require('path'), + _ = require('lodash'), + spawn = require('child_process').spawn; + +var baseDir = path.resolve(__dirname, '..'), + srcDir = path.resolve(baseDir, 'src'); + +cacheVelocityMeteorRelease(); + +function cacheVelocityMeteorRelease() { + console.log('Caching Velocity Meteor Release (can take a while the first time)'); + var childProcess = spawn('meteor', + [ + '--raw-logs', + '--settings', 'settings.json', + '--release', 'velocity:METEOR@1.2.1_2' + ], + { + cwd: srcDir, + env: _.extend({}, process.env, { + VELOCITY: 0 + }) + } + ); + childProcess.stdout.setEncoding('utf8'); + childProcess.stderr.setEncoding('utf8'); + childProcess.stdout.on('data', function (line) { + process.stdout.write(line); + }); + childProcess.stderr.on('data', function (line) { + process.stderr.write(line); + }); + var exitAfterBuild = function exitAfterBuild(line) { + if (line.indexOf('App running at') !== -1) { + childProcess.kill('SIGINT'); + console.log('Done caching Velocity'); + } else if ( + line.indexOf('Your application is crashing') !== -1 || + line.indexOf('Errors prevented startup') !== -1) { + childProcess.kill('SIGINT'); + console.error('There were issues whilst trying to cache the Velocity Meteor release'); + throw new Error(line); + } + }; + childProcess.stdout.on('data', exitAfterBuild); + childProcess.stderr.on('data', exitAfterBuild); +} \ No newline at end of file -- GitLab