INNER CODE UNIT · JavaScript
getServiceName
composerize/composerize · packages/composerize/src/index.js:13
const getServiceName = (image: string): string => {
if (image === null || image === '' || typeof image === 'undefined') return '!!!invalid!!!';
let name = image.includes('/') ? image.split('/').slice(-1)[0] : image;
name = name.includes(':') ? name.split(':')[0] : name;
return name;
};
export type ComposeFile = { composeFile: any, composeCreationComments: string };
const getComposeFileJson = (input: string, existingComposeFile: string): ComposeFile => {
const formattedInput = input
.replace(/\n\s*#[^\n]+/g, '')
.replace(/\$\([^)]*\)/g, (m) => m.replace(/\s/g, '¤'))
.replace(/\\\n/g, '')
.replace(/(\s)+/g, ' ')
.trim()
.replace(/\s-p(\d)/g, ' -p $1')