-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate most tests to the module system (#2003)
- Loading branch information
Showing
280 changed files
with
7,679 additions
and
6,424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Script to run the Sass migrator over a spec directory. | ||
// | ||
// Usage: | ||
// npm run migrate -- directory-to-migrate <migrator> [migrator-options] | ||
|
||
import child_process from 'child_process'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import {fromRoot} from './lib/spec-directory'; | ||
|
||
async function migrate() { | ||
const dirToMigrate = process.argv[2]; | ||
const migratorCommand = process.argv[3]; | ||
const migratorArgs = process.argv.slice(4); | ||
const root = path.resolve(process.cwd(), 'spec'); | ||
const rootDir = await fromRoot('spec'); | ||
|
||
await rootDir.forEachTest( | ||
async testDir => { | ||
const files = (await testDir.listFiles()).filter( | ||
file => file.endsWith('.scss') || file.endsWith('.sass') | ||
); | ||
console.log(testDir.relPath()); | ||
const output = child_process.execFileSync( | ||
path.join( | ||
__dirname, | ||
'node_modules', | ||
'sass-migrator', | ||
'sass-migrator.js' | ||
), | ||
[migratorCommand, `--load-path=${root}`, ...migratorArgs, ...files], | ||
{cwd: testDir.path, encoding: 'utf8'} | ||
); | ||
if (output.length > 0) console.log(output); | ||
// Actually write the migrator's changes to the virtual directory's cache. | ||
for (const file of files) { | ||
await testDir.writeFile( | ||
file, | ||
await fs.promises.readFile(path.join(testDir.path, file), { | ||
encoding: 'utf8', | ||
}) | ||
); | ||
} | ||
}, | ||
[dirToMigrate] | ||
); | ||
} | ||
|
||
migrate(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,43 @@ | ||
<===> too_few/input.scss | ||
a {b: adjust-color()} | ||
@use "sass:color"; | ||
a {b: color.adjust()} | ||
|
||
<===> too_few/error | ||
Error: Missing argument $color. | ||
,--> input.scss | ||
1 | a {b: adjust-color()} | ||
2 | a {b: color.adjust()} | ||
| ^^^^^^^^^^^^^^ invocation | ||
' | ||
,--> sass:color | ||
1 | @function adjust($color, $kwargs...) { | ||
| ========================== declaration | ||
' | ||
input.scss 1:7 root stylesheet | ||
input.scss 2:7 root stylesheet | ||
|
||
<===> | ||
================================================================================ | ||
<===> too_many/input.scss | ||
a {b: adjust-color(red, 1)} | ||
@use "sass:color"; | ||
a {b: color.adjust(red, 1)} | ||
|
||
<===> too_many/error | ||
Error: Only one positional argument is allowed. All other arguments must be passed by name. | ||
, | ||
1 | a {b: adjust-color(red, 1)} | ||
2 | a {b: color.adjust(red, 1)} | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
' | ||
input.scss 1:7 root stylesheet | ||
input.scss 2:7 root stylesheet | ||
|
||
<===> | ||
================================================================================ | ||
<===> unknown/input.scss | ||
a {b: adjust-color(red, $ambience: 10%)} | ||
@use "sass:color"; | ||
a {b: color.adjust(red, $ambience: 10%)} | ||
|
||
<===> unknown/error | ||
Error: No argument named $ambience. | ||
, | ||
1 | a {b: adjust-color(red, $ambience: 10%)} | ||
2 | a {b: color.adjust(red, $ambience: 10%)} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
' | ||
input.scss 1:7 root stylesheet | ||
input.scss 2:7 root stylesheet |
Oops, something went wrong.