Skip to content

Commit

Permalink
Merge pull request #52 from yeojz/fix/website-build
Browse files Browse the repository at this point in the history
fix: website build versioning
  • Loading branch information
yeojz committed Apr 22, 2018
2 parents 53bb9e0 + 2d73d00 commit 1c92ed1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion site/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-console */
const libpkg = require('../../package.json');
const pkg = require('../package.json');
const copyDocs = require('./copyDocs');
const copyFile = require('./copyFile');
Expand All @@ -8,7 +9,7 @@ const PUBLIC_URL = process.env.PUBLIC_URL || pkg.homepage;
const targets = (process.env.BUILD_PKG || '').split(',');

if (targets.indexOf('site') > -1) {
createIndexFile(PUBLIC_URL, pkg);
createIndexFile(PUBLIC_URL, pkg, libpkg.version);

// Library Files
copyFile('../dist/otplib-browser.js', 'dist/lib', '../dist');
Expand Down
4 changes: 2 additions & 2 deletions site/scripts/copyDocs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
const path = require('path');
const ncp = require('ncp').ncp;
const pkg = require('../../package.json');
const libpkg = require('../../package.json');
const directory = require('./directory');

function copyDocs() {
Expand All @@ -14,7 +14,7 @@ function copyDocs() {
};

ncp(
path.join(directory.ROOT, 'docs', pkg.name, pkg.version),
path.join(directory.ROOT, 'docs', libpkg.name, libpkg.version),
path.join(directory.WEBSITE_BUILD, 'docs'),
callback
);
Expand Down
8 changes: 4 additions & 4 deletions site/scripts/createIndexFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require('fs');
const path = require('path');
const directory = require('./directory');

function createIndexFile(PUBLIC_URL, pkg) {
function createIndexFile(PUBLIC_URL, pkg, version) {
const publicUrl = PUBLIC_URL === '/' ? '' : PUBLIC_URL;
const indexFile = path.join(directory.WEBSITE_ROOT, 'public', 'index.html');
const outputFile = path.join(directory.WEBSITE_BUILD, 'index.html');
Expand All @@ -16,9 +16,9 @@ function createIndexFile(PUBLIC_URL, pkg) {

const parsed = content
.toString()
.replace(/\%PUBLIC_URL\%/g, publicUrl)
.replace(/\%KEYWORDS\%/g, pkg.keywords.join(', '))
.replace(/\%PACKAGE_VERSION\%/g, pkg.version);
.replace(/%PUBLIC_URL%/g, publicUrl)
.replace(/%KEYWORDS%/g, pkg.keywords.join(', '))
.replace(/%PACKAGE_VERSION%/g, version);

fs.writeFile(outputFile, parsed, err => {
if (err) {
Expand Down

0 comments on commit 1c92ed1

Please sign in to comment.