Skip to content

Commit

Permalink
fix: throw error if config file is not parsable
Browse files Browse the repository at this point in the history
  • Loading branch information
teclone committed Jun 18, 2024
1 parent 4372e69 commit 96fbea1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
const args = require('args');
const { resolve } = require('path');
const { existsSync } = require('fs');
const { join } = require('path');
const process = require('process');

const parseBoolean = (value) => {
Expand Down Expand Up @@ -88,12 +89,12 @@ args.options([

const run = () => {
const entryPath = process.cwd();
const configFilePath = resolve(entryPath, 'rollup.config.js');
const configFilePath = join(entryPath, 'rollup.config.js');

// inspect package.json file
let pkgFile;
try {
pkgFile = require(resolve(entryPath, 'package.json'));
pkgFile = require(join(entryPath, 'package.json'));
} catch (ex) {
console.error(
'Build failed. cannot locate a package.json file in entry directory'
Expand All @@ -106,7 +107,7 @@ const run = () => {
let camelCase;

try {
moduleExports = require(resolve(
moduleExports = require(join(
__dirname,
pkgFile.name === '@teclone/rollup-all'
? '../temp/index.js'
Expand All @@ -122,9 +123,9 @@ const run = () => {

// resolve config
let config = {};
try {
if (existsSync(configFilePath)) {
config = require(configFilePath);
} catch (ex) {
} else {
console.log(
'Proceeding with no custom defined build config file (rollup.config.js)'
);
Expand Down

0 comments on commit 96fbea1

Please sign in to comment.