Implement renderInstructions in themer-bbedit

This commit is contained in:
Matt Swensen 2020-03-09 06:55:41 -06:00
parent c2a0b06fe7
commit 0561c40d5f
No known key found for this signature in database
GPG Key ID: 3F9E482BFC526F35
4 changed files with 34 additions and 15 deletions

@ -12,8 +12,4 @@ Then pass `themer-bbedit` as a `-t` (`--template`) arg to `themer`:
themer -c my-colors.js -t themer-bbedit -o gen
## Output
`themer-bbedit` will generate a `Themer Dark.bbColorScheme` / `Themer Light.bbColorScheme` (or both) in your output directory.
Copy (or symlink) your theme(s) to `~/Library/Application Support/BBEdit/Color Schemes/`. Your theme will then be available in Preferences > Text Colors > Color Scheme.
Installation instructions for the generated theme file(s) will be included in `<output dir>/README.md`.

@ -313,3 +313,12 @@ exports[`render should render a properly formatted BBEdit theme file 2`] = `
</plist>
"
`;
exports[`renderInstructions should provide installation instructions 1`] = `
"
Copy (or symlink) the files to \`~/Library/Application Support/BBEdit/Color Schemes/\`:
cp 'Themer Dark.bbColorScheme' '~/Library/Application Support/BBEdit/Color Schemes/'
cp 'Themer Light.bbColorScheme' '~/Library/Application Support/BBEdit/Color Schemes/'
"
`;

@ -181,4 +181,12 @@ const render = colors => Object.keys(colors)
}))
.map(colorSet => renderTheme(colorSet));
module.exports = { render };
const destination = '~/Library/Application Support/BBEdit/Color Schemes/';
const renderInstructions = paths => `
Copy (or symlink) the files to \`${destination}\`:
${paths.map(p => ` cp '${p}' '${destination}'`).join('\n')}
`;
module.exports = { render, renderInstructions };

@ -1,15 +1,21 @@
const { render } = require('./index');
const { render, renderInstructions } = require('./index');
const { colors } = require('../../themer-colors-default');
describe('render', () => {
it('should render a properly formatted BBEdit theme file', done => {
Promise.all(render(colors)).then(files => {
expect(files.length).toBe(2);
files.forEach(file => {
expect(/Themer (Dark|Light)\.bbColorScheme/.test(file.name)).toBe(true);
expect(file.contents.toString('utf8')).toMatchSnapshot();
});
done();
it('should render a properly formatted BBEdit theme file', async () => {
const files = await Promise.all(render(colors))
expect(files.length).toBe(2);
files.forEach(file => {
expect(/Themer (Dark|Light)\.bbColorScheme/.test(file.name)).toBe(true);
expect(file.contents.toString('utf8')).toMatchSnapshot();
});
});
});
describe('renderInstructions', () => {
it('should provide installation instructions', async () => {
const files = await Promise.all(render(colors));
const instructions = renderInstructions(files.map(({ name }) => name));
expect(instructions).toMatchSnapshot();
});
});