mirror of
https://github.com/sparksp/elm-format-action.git
synced 2024-11-24 05:30:45 +03:00
Upgrade jest and typescript
This commit is contained in:
parent
b6d93d3b07
commit
8d3034bedb
@ -6,36 +6,27 @@ test('runs quietly on success', () => {
|
||||
process.env['INPUT_ELM_FORMAT'] = 'elm-format'
|
||||
process.env['INPUT_ELM_FILES'] = '__tests__/elm/Good.elm'
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecSyncOptions = {
|
||||
env: process.env
|
||||
const options: cp.SpawnOptions = {
|
||||
env: process.env,
|
||||
shell: true
|
||||
}
|
||||
|
||||
let status
|
||||
try {
|
||||
cp.execSync(`node ${ip}`, options)
|
||||
} catch (e) {
|
||||
status = e.status
|
||||
}
|
||||
expect(status).toBeUndefined() // Success!
|
||||
let ret = cp.spawnSync(`node ${ip}`, options)
|
||||
expect(ret.status).toBe(0)
|
||||
})
|
||||
|
||||
test('reports errors', () => {
|
||||
process.env['INPUT_ELM_FORMAT'] = 'elm-format'
|
||||
process.env['INPUT_ELM_FILES'] = '__tests__/elm/Bad.elm'
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecSyncOptions = {
|
||||
env: process.env
|
||||
const options: cp.SpawnOptions = {
|
||||
env: process.env,
|
||||
shell: true
|
||||
}
|
||||
|
||||
let stdout, status
|
||||
try {
|
||||
stdout = cp.execSync(`node ${ip}`, options)
|
||||
} catch (e) {
|
||||
status = e.status
|
||||
stdout = e.stdout
|
||||
}
|
||||
expect(status).toBe(1)
|
||||
expect(stdout.toString()).toBe(
|
||||
let ret = cp.spawnSync(`node ${ip}`, options)
|
||||
expect(ret.status).toBe(1)
|
||||
expect(ret.stdout.toString()).toBe(
|
||||
'::error file=__tests__/elm/Bad.elm::File is not formatted with elm-format-0.8.5 --elm-version=0.19\n' +
|
||||
'::error::elm-format reported errors with 1 file\n'
|
||||
)
|
||||
@ -45,19 +36,14 @@ test('handles bad file input', () => {
|
||||
process.env['INPUT_ELM_FORMAT'] = 'elm-format'
|
||||
process.env['INPUT_ELM_FILES'] = '__tests__/elm/Missing.elm'
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecSyncOptions = {
|
||||
env: process.env
|
||||
const options: cp.SpawnOptions = {
|
||||
env: process.env,
|
||||
shell: true
|
||||
}
|
||||
|
||||
let status, stdout
|
||||
try {
|
||||
stdout = cp.execSync(`node ${ip}`, options)
|
||||
} catch (e) {
|
||||
status = e.status
|
||||
stdout = e.stdout
|
||||
}
|
||||
expect(status).toBe(1) // Something went wrong
|
||||
expect(stdout.toString()).toContain('::error::')
|
||||
let ret = cp.spawnSync(`node ${ip}`, options)
|
||||
expect(ret.status).toBe(1) // Something went wrong
|
||||
expect(ret.stdout.toString()).toContain('::error::')
|
||||
})
|
||||
|
||||
test('runs globs', () => {
|
||||
@ -65,17 +51,13 @@ test('runs globs', () => {
|
||||
process.env['INPUT_ELM_FILES'] = '__tests__/**/*.elm\n!**/Bad.elm'
|
||||
process.env['INPUT_ELM_GLOB'] = 'true'
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecSyncOptions = {
|
||||
env: process.env
|
||||
const options: cp.SpawnOptions = {
|
||||
env: process.env,
|
||||
shell: true
|
||||
}
|
||||
|
||||
let status
|
||||
try {
|
||||
cp.execSync(`node ${ip}`, options)
|
||||
} catch (e) {
|
||||
status = e.status
|
||||
}
|
||||
expect(status).toBeUndefined() // Success!
|
||||
let ret = cp.spawnSync(`node ${ip}`, options)
|
||||
expect(ret.status).toBe(0) // Success!
|
||||
})
|
||||
|
||||
test('handles no files input', () => {
|
||||
@ -83,17 +65,12 @@ test('handles no files input', () => {
|
||||
process.env['INPUT_ELM_FILES'] = 'Missing.elm'
|
||||
process.env['INPUT_ELM_GLOB'] = 'true'
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecSyncOptions = {
|
||||
env: process.env
|
||||
const options: cp.SpawnOptions = {
|
||||
env: process.env,
|
||||
shell: true
|
||||
}
|
||||
|
||||
let status, stdout
|
||||
try {
|
||||
stdout = cp.execSync(`node ${ip}`, options)
|
||||
} catch (e) {
|
||||
status = e.status
|
||||
stdout = e.stdout
|
||||
}
|
||||
expect(status).toBe(1) // Something went wrong
|
||||
expect(stdout.toString()).toContain('::error::No Elm files found')
|
||||
let ret = cp.spawnSync(`node ${ip}`, options)
|
||||
expect(ret.status).toBe(1) // Something went wrong
|
||||
expect(ret.stdout.toString()).toContain('::error::No Elm files found')
|
||||
})
|
||||
|
8
dist/index.js
vendored
8
dist/index.js
vendored
@ -2676,7 +2676,11 @@ exports.checkBypass = checkBypass;
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
@ -2753,7 +2757,7 @@ const runElmFormat = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const issueErrors = (report) => {
|
||||
let reported = 0;
|
||||
for (const message of report) {
|
||||
command_1.issueCommand('error', { file: message.path }, message.message);
|
||||
(0, command_1.issueCommand)('error', { file: message.path }, message.message);
|
||||
reported++;
|
||||
}
|
||||
return reported;
|
||||
|
12
package.json
12
package.json
@ -33,8 +33,8 @@
|
||||
"@actions/glob": "^0.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node": "^14.14.20",
|
||||
"@types/jest": "^29.2.4",
|
||||
"@types/node": "^18.11.13",
|
||||
"@typescript-eslint/parser": "^5.46.0",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"elm-tooling": "^1.10.0",
|
||||
@ -42,12 +42,12 @@
|
||||
"eslint-plugin-github": "^4.6.0",
|
||||
"eslint-plugin-jest": "^27.1.6",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"jest": "^29.3.1",
|
||||
"jest-circus": "^29.3.1",
|
||||
"js-yaml": "^4.0.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.2.1",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.1.3"
|
||||
"ts-jest": "^29.0.3",
|
||||
"typescript": "^4.9.4"
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ async function run(): Promise<void> {
|
||||
const report = await runElmFormat()
|
||||
reportFailure(issueErrors(report))
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
core.setFailed((error as Error).message)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,4 +10,3 @@
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user