Skip to content

Commit 96fbea1

Browse files
Harrison IfeanyichukwuHarrison Ifeanyichukwu
authored andcommitted
fix: throw error if config file is not parsable
1 parent 4372e69 commit 96fbea1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bin/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22
const args = require('args');
3-
const { resolve } = require('path');
3+
const { existsSync } = require('fs');
4+
const { join } = require('path');
45
const process = require('process');
56

67
const parseBoolean = (value) => {
@@ -88,12 +89,12 @@ args.options([
8889

8990
const run = () => {
9091
const entryPath = process.cwd();
91-
const configFilePath = resolve(entryPath, 'rollup.config.js');
92+
const configFilePath = join(entryPath, 'rollup.config.js');
9293

9394
// inspect package.json file
9495
let pkgFile;
9596
try {
96-
pkgFile = require(resolve(entryPath, 'package.json'));
97+
pkgFile = require(join(entryPath, 'package.json'));
9798
} catch (ex) {
9899
console.error(
99100
'Build failed. cannot locate a package.json file in entry directory'
@@ -106,7 +107,7 @@ const run = () => {
106107
let camelCase;
107108

108109
try {
109-
moduleExports = require(resolve(
110+
moduleExports = require(join(
110111
__dirname,
111112
pkgFile.name === '@teclone/rollup-all'
112113
? '../temp/index.js'
@@ -122,9 +123,9 @@ const run = () => {
122123

123124
// resolve config
124125
let config = {};
125-
try {
126+
if (existsSync(configFilePath)) {
126127
config = require(configFilePath);
127-
} catch (ex) {
128+
} else {
128129
console.log(
129130
'Proceeding with no custom defined build config file (rollup.config.js)'
130131
);

0 commit comments

Comments
 (0)