mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 11:35:28 +00:00
21 lines
501 B
TypeScript
21 lines
501 B
TypeScript
import * as fs from 'fs';
|
|
|
|
export default function validate_bundler(bundler?: string) {
|
|
if (!bundler) {
|
|
bundler = (
|
|
fs.existsSync('rollup') ? 'rollup' :
|
|
fs.existsSync('webpack') ? 'webpack' :
|
|
null
|
|
);
|
|
|
|
if (!bundler) {
|
|
throw new Error(`Could not find a 'rollup' or 'webpack' directory`);
|
|
}
|
|
}
|
|
|
|
if (bundler !== 'rollup' && bundler !== 'webpack') {
|
|
throw new Error(`'${bundler}' is not a valid option for --bundler — must be either 'rollup' or 'webpack'`);
|
|
}
|
|
|
|
return bundler;
|
|
} |