Skip to content

Commit

Permalink
Deletes inlineStyleLegacy().
Browse files Browse the repository at this point in the history
There is no more need for this since the new `inlineStyle()` function has shipped.
  • Loading branch information
dgp1130 committed May 3, 2022
1 parent eb5d3ef commit 831b592
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 38 deletions.
1 change: 0 additions & 1 deletion packages/rules_prerender/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ ts_library(
name = "styles_test_lib",
srcs = ["styles_test.ts"],
testonly = True,
data = ["//packages/rules_prerender/testdata:styles.css"],
deps = [
":inline_style_map",
":styles",
Expand Down
2 changes: 1 addition & 1 deletion packages/rules_prerender/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

export { PrerenderResource } from 'rules_prerender/common/models/prerender_resource';
export { includeScript } from 'rules_prerender/packages/rules_prerender/scripts';
export { includeStyle, inlineStyle, inlineStyleLegacy } from 'rules_prerender/packages/rules_prerender/styles';
export { includeStyle, inlineStyle } from 'rules_prerender/packages/rules_prerender/styles';
13 changes: 0 additions & 13 deletions packages/rules_prerender/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,3 @@ export class InlineStyleNotFoundError extends Error {
});
}
}

/**
* Reads the given CSS file at the provided runfiles path and returns it in a
* `<style />` tag to be inlined in the document.
*/
export async function inlineStyleLegacy(path: string): Promise<string> {
const styles = await fs.readFile(runfiles.resolve(path), 'utf-8');
return `
<style>
${styles}
</style>
`.trim();
}
20 changes: 1 addition & 19 deletions packages/rules_prerender/styles_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'jasmine';

import * as inlineStyleMap from 'rules_prerender/packages/rules_prerender/inline_style_map';
import { createAnnotation, StyleScope } from 'rules_prerender/common/models/prerender_annotation';
import { includeStyle, inlineStyle, inlineStyleLegacy, InlineStyleNotFoundError } from 'rules_prerender/packages/rules_prerender/styles';
import { includeStyle, inlineStyle, InlineStyleNotFoundError } from 'rules_prerender/packages/rules_prerender/styles';

describe('styles', () => {
describe('includeStyle()', () => {
Expand Down Expand Up @@ -58,22 +58,4 @@ describe('styles', () => {
})} -->`);
});
});

describe('inlineStyleLegacy()', () => {
it('resolves to a `<style />` element with the runfiles content of the given file path', async () => {
const styles = await inlineStyleLegacy(
'rules_prerender/packages/rules_prerender/testdata/styles.css');
expect(styles).toBe(`
<style>
.foo { color: red; }
</style>
`.trim());
});

it('rejects when the given file path is not found in runfiles', async () => {
await expectAsync(inlineStyleLegacy('rules_prerender/does/not/exist.css'))
.toBeRejected();
});
});
});
3 changes: 0 additions & 3 deletions packages/rules_prerender/testdata/BUILD.bazel

This file was deleted.

1 change: 0 additions & 1 deletion packages/rules_prerender/testdata/styles.css

This file was deleted.

0 comments on commit 831b592

Please sign in to comment.