diff --git a/buildutils/src/ensure-package.ts b/buildutils/src/ensure-package.ts index 2e007c8f972f..f4665ada0cd4 100644 --- a/buildutils/src/ensure-package.ts +++ b/buildutils/src/ensure-package.ts @@ -349,7 +349,10 @@ export async function ensureUiComponents(pkgPath: string): Promise { const name = utils.stem(svg); const nameCamel = utils.camelCase(name) + 'Svg'; _iconImportStatements.push( - `import ${nameCamel} from '${path.relative(iconSrcDir, svg)}';` + `import ${nameCamel} from '${path + .relative(iconSrcDir, svg) + .split(path.sep) + .join('/')}';` ); _iconModelDeclarations.push(`{ name: '${name}', svg: ${nameCamel} }`); }); @@ -376,7 +379,10 @@ export async function ensureUiComponents(pkgPath: string): Promise { const className = 'jp-' + utils.camelCase(name, true) + 'Icon'; _iconCSSUrls.push( - `--${urlName}: url('${path.relative(iconCSSDir, svg)}');` + `--${urlName}: url('${path + .relative(iconCSSDir, svg) + .split(path.sep) + .join('/')}');` ); _iconCSSDeclarations.push( `.${className} {background-image: var(--${urlName})}` @@ -485,6 +491,10 @@ function ensureFile( const prev = fs.readFileSync(path, { encoding: 'utf8' }); + // Normalize line endings to match current content + if (prev.indexOf('\r') !== -1) { + contents = contents.replace(/\n/g, '\r\n'); + } if (prev !== contents) { fs.writeFileSync(path, contents); messages.push(`Updated ./${path}`);