Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build util paths for Windows #7019

Merged
merged 1 commit into from Aug 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions buildutils/src/ensure-package.ts
Expand Up @@ -349,7 +349,10 @@ export async function ensureUiComponents(pkgPath: string): Promise<string[]> {
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} }`);
});
Expand All @@ -376,7 +379,10 @@ export async function ensureUiComponents(pkgPath: string): Promise<string[]> {
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})}`
Expand Down Expand Up @@ -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}`);
Expand Down