Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/javascript/packages/build-sass/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## Unreleased
## 1.3.0

### Improvements

- Adds support for ".scss" file extension, as an alternative to the current ".css.scss" support. In both cases, the output files use the basename with a ".css" extension.
- Creates the `--out-dir` directory if it does not exist already.
- Outputs any error that occurs during build, not just Sass compilation errors.

## 1.2.0

Expand Down
10 changes: 7 additions & 3 deletions app/javascript/packages/build-sass/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/* eslint-disable no-console */

import { mkdir } from 'node:fs/promises';
import { watch } from 'chokidar';
import { fileURLToPath } from 'url';
import { parseArgs } from '@pkgjs/parseargs'; // Note: Use native util.parseArgs after Node v18
Expand Down Expand Up @@ -80,6 +81,9 @@ function build(files) {
);
}

build(fileArgs).catch(() => {
process.exitCode = 1;
});
mkdir(outDir, { recursive: true })
.then(() => build(fileArgs))
.catch((error) => {
console.error(error);
process.exitCode = 1;
});
21 changes: 21 additions & 0 deletions app/javascript/packages/build-sass/cli.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { promisify } from 'node:util';
import { stat } from 'node:fs/promises';
import { exec as execCallback } from 'node:child_process';

const exec = promisify(execCallback);
const cwd = dirname(fileURLToPath(import.meta.url));

describe('cli', () => {
context('with missing output directory', () => {
it('creates the output directory', async () => {
await exec(
'./cli.js fixtures/missing-out-dir/in.css.scss --out-dir=fixtures/missing-out-dir/out',
{ cwd },
);

await stat(join(cwd, 'fixtures/missing-out-dir/in.css.scss'));
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

  • We deleted app/assets/builds/.keep (an empty file)
  • We added an empty file for the fixture, in.css.scss

Git interpreted this as a "move".

Empty file.
2 changes: 1 addition & 1 deletion app/javascript/packages/build-sass/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@18f/identity-build-sass",
"version": "1.2.0",
"version": "1.3.0",
"private": false,
"description": "Stylesheet compilation utility with reasonable defaults and fast performance.",
"type": "module",
Expand Down