Skip to content

Commit

Permalink
Merge pull request #535 from opentable/buildFix
Browse files Browse the repository at this point in the history
Fix grunt build to override package version
  • Loading branch information
nickbalestra authored Jul 11, 2017
2 parents d609b22 + a1bf89a commit 9266948
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ results
*.orig
*.local
.DS_Store
.vscode

npm-debug.log
node_modules
Expand Down
11 changes: 11 additions & 0 deletions tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,31 @@ const fs = require('fs-extra');
const ocClientBrowser = require('oc-client-browser');
const path = require('path');
const uglifyJs = require('uglify-js');
const packageJson = require('../package');

module.exports = function(grunt) {
grunt.registerTask(
'build',
'Builds and minifies the oc-client component',
function() {
const done = this.async();
const ocVersion = packageJson.version;
const clientComponentDir = '../src/components/oc-client/';
const ocClientPackageInfo = require(`${clientComponentDir}package.json`);

fs.emptyDirSync(path.join(__dirname, clientComponentDir, 'src'));
ocClientBrowser.getLib((err, libContent) => {
if (err) {
grunt.log['error'](err);
}

ocClientPackageInfo.version = ocVersion;
fs.writeJsonSync(
path.join(__dirname, clientComponentDir, 'package.json'),
ocClientPackageInfo,
{ spaces: 2 }
);

fs.writeFileSync(
path.join(__dirname, clientComponentDir, 'src/oc-client.min.js'),
libContent
Expand Down

0 comments on commit 9266948

Please sign in to comment.