mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-12-23 18:48:55 +00:00
1505933826
Instead of optionsMain exporting an async function, this commit changes it to return a promise instead. We split all the needed async helpers for this config builder into smaller promises, in `src/options/*`. Another side effect of this is that we perform all our async config inferring in parallel, which speeds up the nativefier CLI. Add proper unit tests as well for all of these promises. Switch to Jest for these unit tests, and we are temporarily running both Jest and mocha together in `npm test`. To refactor all the Mocha code to use Jest in a future commit.
18 lines
532 B
JavaScript
18 lines
532 B
JavaScript
import _ from 'lodash';
|
|
import sanitizeFilenameLib from 'sanitize-filename';
|
|
import { DEFAULT_APP_NAME } from './../constants';
|
|
|
|
export default function (platform, str) {
|
|
let result = sanitizeFilenameLib(str);
|
|
|
|
// remove all non ascii or use default app name
|
|
// eslint-disable-next-line no-control-regex
|
|
result = result.replace(/[^\x00-\x7F]/g, '') || DEFAULT_APP_NAME;
|
|
|
|
// spaces will cause problems with Ubuntu when pinned to the dock
|
|
if (platform === 'linux') {
|
|
return _.kebabCase(result);
|
|
}
|
|
return result;
|
|
}
|