Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make yarn-run-dev not move queries.json to build folder #162

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
12 changes: 12 additions & 0 deletions bin/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ if (args.h || args.help || args._.length > 1) {
const baseURL = args.b || 'https://query.linkeddatafragments.org/';
const webpackConfig = require(args.w ? path.resolve(process.cwd(), args.w) : '../webpack.config.js');

// Remove the location of queries.json which shouldn't be present in the build configuration.
webpackConfig[0].entry=webpackConfig[0].entry.filter(x => !x.endsWith('queries.json'));

// Override the baseURL in the webpack config
webpackConfig.baseURL.replace = baseURL;

Expand All @@ -66,6 +69,7 @@ if (args.h || args.help || args._.length > 1) {
entry.output.path = path.resolve(process.cwd(), destinationPath);
}
}

webpack(webpackConfig, (err, stats) => {
if (err) {
console.error(err.stack || err);
Expand All @@ -82,4 +86,12 @@ if (args.h || args.help || args._.length > 1) {

fs.unlinkSync('.tmp-comunica-engine.js');
});

if (fs.existsSync(path.join(process.cwd(), 'queries.json'))) {
// Create the build output folder if it doesn't exist
if (! fs.existsSync(path.resolve(process.cwd(), destinationPath))) {
fs.mkdirSync(path.resolve(process.cwd(), destinationPath));
}
fs.renameSync(path.join(process.cwd(), 'queries.json'), path.resolve(process.cwd(), `${destinationPath}/queries.json`));
};
})();
Loading