Skip to content

Commit

Permalink
Add oxd build script (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
RajithaKumara authored Sep 27, 2021
1 parent f192531 commit df9bc5d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
node_modules
/dist
/build


# local env files
Expand Down
60 changes: 60 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* This file is part of OrangeHRM Inc
*
* Copyright (C) 2020 onwards OrangeHRM Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses
*/

const fs = require('fs');
const path = require('path');

const projectRootDir = path.join(__dirname, '..');
const pathToBuildDir = path.join(projectRootDir, 'build');
if (fs.existsSync(pathToBuildDir)) {
fs.rmdirSync(pathToBuildDir, { recursive: true })
}

fs.mkdirSync(pathToBuildDir);

const rootDirFiles = ['LICENSE', 'README.md', 'tsconfig.json', 'postcss.config.js'];
rootDirFiles.forEach(function (file) {
fs.copyFileSync(path.join(projectRootDir, file), path.join(pathToBuildDir, file));
});

const pathToComponentsDir = path.join(projectRootDir, 'components');
const componentsDirFiles = ['package.json', 'babel.config.js', '.browserslistrc'];
componentsDirFiles.forEach(function (file) {
fs.copyFileSync(path.join(pathToComponentsDir, file), path.join(pathToBuildDir, file));
})

const copyRecursiveSync = function (src, dest) {
const exists = fs.existsSync(src);
const stats = exists && fs.statSync(src);
const isDirectory = exists && stats.isDirectory();
if (isDirectory) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
fs.readdirSync(src).forEach(function (childItemName) {
copyRecursiveSync(path.join(src, childItemName),
path.join(dest, childItemName));
});
} else {
fs.copyFileSync(src, dest);
}
};

copyRecursiveSync(path.join(pathToComponentsDir, 'src'), pathToBuildDir);

0 comments on commit df9bc5d

Please sign in to comment.