2021-03-04 17:49:52 +03:00
|
|
|
import { command } from 'execa'
|
2019-02-10 15:26:50 +03:00
|
|
|
|
2022-09-26 16:29:56 +03:00
|
|
|
import { LogHelper } from '@/helpers/log-helper'
|
2022-09-26 16:24:07 +03:00
|
|
|
import { LoaderHelper } from '@/helpers/loader-helper'
|
2019-02-10 15:26:50 +03:00
|
|
|
|
2022-09-16 23:36:45 +03:00
|
|
|
const globs = [
|
|
|
|
'"app/src/js/*.{ts,js}"',
|
|
|
|
// TODO: deal with it once handling new hotword
|
|
|
|
// '"hotword/index.{ts,js}"',
|
|
|
|
// TODO: put it back once tests have been reintroduced into skills
|
|
|
|
// '"skills/**/*.js"',
|
|
|
|
'"scripts/**/*.{ts,js}"',
|
|
|
|
'"server/src/**/*.{ts,js}"'
|
|
|
|
// TODO: put it back once tests need to be written
|
|
|
|
/*'"test/!*.js"',
|
|
|
|
'"test/e2e/!**!/!*.js"',
|
|
|
|
'"test/json/!**!/!*.js"',
|
|
|
|
'"test/unit/!**!/!*.js"'*/
|
|
|
|
]
|
|
|
|
const src = globs.join(' ')
|
|
|
|
|
|
|
|
async function prettier() {
|
|
|
|
await command('prettier --write . --ignore-path .gitignore', {
|
|
|
|
shell: true
|
|
|
|
})
|
|
|
|
await command(`prettier --check ${src} --ignore-path .gitignore`, {
|
|
|
|
shell: true,
|
|
|
|
stdio: 'inherit'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-02-10 15:26:50 +03:00
|
|
|
/**
|
|
|
|
* This script ensures the correct coding syntax of the whole project
|
|
|
|
*/
|
2022-09-03 14:12:41 +03:00
|
|
|
;(async () => {
|
2022-09-26 16:24:07 +03:00
|
|
|
LoaderHelper.start()
|
2022-09-26 16:29:56 +03:00
|
|
|
LogHelper.info('Linting...')
|
2019-02-10 15:26:50 +03:00
|
|
|
|
|
|
|
try {
|
2022-09-16 23:36:45 +03:00
|
|
|
await Promise.all([
|
|
|
|
prettier(),
|
|
|
|
command(`eslint ${src} --ignore-path .gitignore`, {
|
|
|
|
shell: true,
|
|
|
|
stdio: 'inherit'
|
|
|
|
})
|
|
|
|
])
|
2019-02-10 15:26:50 +03:00
|
|
|
|
2022-09-26 16:29:56 +03:00
|
|
|
LogHelper.success('Looks great')
|
2022-09-26 16:24:07 +03:00
|
|
|
LoaderHelper.stop()
|
2019-02-10 15:26:50 +03:00
|
|
|
} catch (e) {
|
2022-09-26 16:29:56 +03:00
|
|
|
LogHelper.error(`Does not look great: ${e.message}`)
|
2022-09-26 16:24:07 +03:00
|
|
|
LoaderHelper.stop()
|
2019-02-10 15:26:50 +03:00
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
})()
|