Skip to content

Commit

Permalink
fix(spack): config file fix
Browse files Browse the repository at this point in the history
  • Loading branch information
3axap4eHko committed Mar 20, 2023
1 parent 3315419 commit 15803dd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions node-swc/src/spack.ts
Expand Up @@ -4,12 +4,15 @@ import { Options } from "./types";

export type BundleInput = BundleOptions | BundleOptions[];

export const isLocalFile = /^\.{0,2}\//; // starts with '/' './' '../'

export async function compileBundleOptions(config: BundleInput | string | undefined): Promise<BundleInput> {
const f = config === undefined ? '.' : config;

try {
const file = typeof f === 'string' ? f : path.resolve('spack.config.js');
let configFromFile: BundleInput = require(file);
const filepath = typeof f === 'string' ? f : 'spack.config.js';
const fileModule = isLocalFile.test(filepath) ? path.resolve(filepath) : filepath;
let configFromFile: BundleInput = require(fileModule);
if ((configFromFile as any).default) {
configFromFile = (configFromFile as any).default;
}
Expand Down

0 comments on commit 15803dd

Please sign in to comment.