feat: warnOnce & graceful error handling

This commit is contained in:
Igor Randjelovic
2021-04-01 17:55:45 +02:00
parent 7edb1e90b0
commit 1627f52043
4 changed files with 40 additions and 8 deletions

View File

@ -1,7 +1,7 @@
import { dirname, resolve } from 'path';
import { getPackageJson, getProjectRootPath } from './project';
import { error, info } from './log';
import { error, info, warnOnce } from './log';
import { env } from '../';
import AndroidPlatform from '../platforms/android';
@ -65,13 +65,20 @@ export function getPlatformName(): Platform {
`);
}
throw error(`
warnOnce(
'getPlatformName',
`
You need to provide a target platform!
Available platforms: ${Object.keys(platforms).join(', ')}
Use --env.platform=<platform> or --env.android, --env.ios to specify the target platform.
`);
Defaulting to "ios".
`
);
return 'ios';
}
/**