-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
30 additions
and
41 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
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,44 +1,33 @@ | ||
import { execSync } from 'node:child_process' | ||
import { | ||
copyFileSync, | ||
existsSync, | ||
mkdirSync, | ||
readFileSync, | ||
rmdirSync, | ||
} from 'node:fs' | ||
import { resolve } from 'node:path' | ||
|
||
import * as cp from 'node:child_process' | ||
import * as fs from 'node:fs' | ||
import * as os from 'node:os' | ||
import * as path from 'node:path' | ||
import * as prettierConfig from '../../main/js' | ||
|
||
describe('', () => { | ||
const tmpDir = resolve(__dirname, '../../../../../tmp') | ||
const root = path.resolve(__dirname, '../../../../../') | ||
const bin = path.resolve(root, 'node_modules/.bin/prettier') | ||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tempy-')) | ||
|
||
describe('prettier', () => { | ||
beforeAll(() => { | ||
if (existsSync(tmpDir)) { | ||
rmdirSync(tmpDir, { recursive: true }) | ||
if (fs.existsSync(tmpDir)) { | ||
fs.rmSync(tmpDir, { recursive: true }) | ||
} | ||
mkdirSync(tmpDir) | ||
fs.mkdirSync(tmpDir) | ||
}) | ||
|
||
it('prettierConfig', () => { | ||
expect(prettierConfig).toBeDefined() | ||
}) | ||
|
||
it('formats as expected', async () => { | ||
const configPath = resolve(__dirname, '../../main/js/index.js') | ||
|
||
const prettier = resolve( | ||
__dirname, | ||
'../../../../../node_modules/.bin/prettier', | ||
) | ||
const input = resolve(__dirname, '../fixtures/input.ts') | ||
const output = resolve(__dirname, '../fixtures/output.ts') | ||
const temp = resolve(tmpDir, 'index.ts') | ||
|
||
copyFileSync(input, temp) | ||
|
||
execSync(`${prettier} --config ${configPath} --write ${temp}`) | ||
|
||
expect(readFileSync(temp, 'utf-8')).toBe(readFileSync(output, 'utf-8')) | ||
const configPath = path.resolve(__dirname, '../../main/js/index.js') | ||
const input = path.resolve(__dirname, '../fixtures/input.ts') | ||
const output = path.resolve(__dirname, '../fixtures/output.ts') | ||
const index = path.resolve(tmpDir, 'index.ts') | ||
|
||
fs.copyFileSync(input, index) | ||
cp.execSync(`${bin} --config ${configPath} --write ${tmpDir}`) | ||
Check warning Code scanning / CodeQL Shell command built from environment values Medium test
This shell command depends on an uncontrolled
absolute path Error loading related location Loading This shell command depends on an uncontrolled absolute path Error loading related location Loading This shell command depends on an uncontrolled absolute path Error loading related location Loading |
||
expect(fs.readFileSync(index, 'utf-8')).toBe(fs.readFileSync(output, 'utf-8')) | ||
}) | ||
}) |
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