mirror of
https://github.com/actions/configure-pages.git
synced 2026-03-30 10:04:52 +00:00
Add prettier configuration
This commit is contained in:
@@ -1,83 +1,104 @@
|
||||
const { ConfigParser } = require('./config-parser')
|
||||
const fs = require("fs")
|
||||
const {ConfigParser} = require('./config-parser')
|
||||
const fs = require('fs')
|
||||
const assert = require('assert')
|
||||
|
||||
const srcFolder = `${process.cwd()}/src/fixtures`
|
||||
const tmpFolder = `${process.cwd()}/src/fixtures/tmp`
|
||||
const expectedFolder = `${process.cwd()}/src/fixtures/expected`
|
||||
|
||||
const repoPath = "/amazing-new-repo/"
|
||||
const repoPath = '/amazing-new-repo/'
|
||||
|
||||
const cases = [
|
||||
["next.config.js", {
|
||||
filePath: `${tmpFolder}/next.config.js`,
|
||||
type: "next",
|
||||
pathName: "basePath",
|
||||
newPath: repoPath
|
||||
}],
|
||||
["next.config.old.js", {
|
||||
filePath: `${tmpFolder}/next.config.old.js`,
|
||||
type: "next",
|
||||
pathName: "basePath",
|
||||
newPath: repoPath
|
||||
}],
|
||||
["next.config.old.missing.js", {
|
||||
filePath: `${tmpFolder}/next.config.old.missing.js`,
|
||||
type: "next",
|
||||
pathName: "basePath",
|
||||
newPath: repoPath
|
||||
}],
|
||||
["gatsby-config.js", {
|
||||
filePath: `${tmpFolder}/gatsby-config.js`,
|
||||
type: "gatsby",
|
||||
pathName: "pathPrefix",
|
||||
newPath: repoPath
|
||||
}],
|
||||
["gatsby-config.old.js", {
|
||||
filePath: `${tmpFolder}/gatsby-config.old.js`,
|
||||
type: "gatsby",
|
||||
pathName: "pathPrefix",
|
||||
newPath: repoPath
|
||||
}],
|
||||
["nuxt.config.js", {
|
||||
filePath:`${tmpFolder}/nuxt.config.js`,
|
||||
type: "nuxt",
|
||||
pathName: "router",
|
||||
subPathName: "base",
|
||||
newPath: repoPath
|
||||
}],
|
||||
["nuxt.config.missing.js", {
|
||||
filePath:`${tmpFolder}/nuxt.config.missing.js`,
|
||||
type: "nuxt",
|
||||
pathName: "router",
|
||||
subPathName: "base",
|
||||
newPath: repoPath
|
||||
}],
|
||||
["nuxt.config.old.js", {
|
||||
filePath:`${tmpFolder}/nuxt.config.old.js`,
|
||||
type: "nuxt",
|
||||
pathName: "router",
|
||||
subPathName: "base",
|
||||
newPath: repoPath
|
||||
}],
|
||||
];
|
||||
[
|
||||
'next.config.js',
|
||||
{
|
||||
filePath: `${tmpFolder}/next.config.js`,
|
||||
type: 'next',
|
||||
pathName: 'basePath',
|
||||
newPath: repoPath
|
||||
}
|
||||
],
|
||||
[
|
||||
'next.config.old.js',
|
||||
{
|
||||
filePath: `${tmpFolder}/next.config.old.js`,
|
||||
type: 'next',
|
||||
pathName: 'basePath',
|
||||
newPath: repoPath
|
||||
}
|
||||
],
|
||||
[
|
||||
'next.config.old.missing.js',
|
||||
{
|
||||
filePath: `${tmpFolder}/next.config.old.missing.js`,
|
||||
type: 'next',
|
||||
pathName: 'basePath',
|
||||
newPath: repoPath
|
||||
}
|
||||
],
|
||||
[
|
||||
'gatsby-config.js',
|
||||
{
|
||||
filePath: `${tmpFolder}/gatsby-config.js`,
|
||||
type: 'gatsby',
|
||||
pathName: 'pathPrefix',
|
||||
newPath: repoPath
|
||||
}
|
||||
],
|
||||
[
|
||||
'gatsby-config.old.js',
|
||||
{
|
||||
filePath: `${tmpFolder}/gatsby-config.old.js`,
|
||||
type: 'gatsby',
|
||||
pathName: 'pathPrefix',
|
||||
newPath: repoPath
|
||||
}
|
||||
],
|
||||
[
|
||||
'nuxt.config.js',
|
||||
{
|
||||
filePath: `${tmpFolder}/nuxt.config.js`,
|
||||
type: 'nuxt',
|
||||
pathName: 'router',
|
||||
subPathName: 'base',
|
||||
newPath: repoPath
|
||||
}
|
||||
],
|
||||
[
|
||||
'nuxt.config.missing.js',
|
||||
{
|
||||
filePath: `${tmpFolder}/nuxt.config.missing.js`,
|
||||
type: 'nuxt',
|
||||
pathName: 'router',
|
||||
subPathName: 'base',
|
||||
newPath: repoPath
|
||||
}
|
||||
],
|
||||
[
|
||||
'nuxt.config.old.js',
|
||||
{
|
||||
filePath: `${tmpFolder}/nuxt.config.old.js`,
|
||||
type: 'nuxt',
|
||||
pathName: 'router',
|
||||
subPathName: 'base',
|
||||
newPath: repoPath
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
describe('configParser', () => {
|
||||
test.each(cases)(
|
||||
"%p parsed correctly",
|
||||
(fileName, configuration) => {
|
||||
srcFileName = `${srcFolder}/${fileName}`
|
||||
tmpFileName = `${tmpFolder}/${fileName}`
|
||||
expectedFileName = `${expectedFolder}/${fileName}`
|
||||
fs.mkdirSync(tmpFolder, {recursive: true})
|
||||
fs.copyFileSync(srcFileName, tmpFileName)
|
||||
const parser = new ConfigParser(configuration)
|
||||
parser.parse()
|
||||
test.each(cases)('%p parsed correctly', (fileName, configuration) => {
|
||||
srcFileName = `${srcFolder}/${fileName}`
|
||||
tmpFileName = `${tmpFolder}/${fileName}`
|
||||
expectedFileName = `${expectedFolder}/${fileName}`
|
||||
fs.mkdirSync(tmpFolder, {recursive: true})
|
||||
fs.copyFileSync(srcFileName, tmpFileName)
|
||||
const parser = new ConfigParser(configuration)
|
||||
parser.parse()
|
||||
|
||||
var expectedContent = fs.readFileSync(expectedFileName).toString()
|
||||
var actualContent = fs.readFileSync(tmpFileName).toString()
|
||||
assert.equal(actualContent, expectedContent)
|
||||
fs.rmSync(tmpFileName)
|
||||
}
|
||||
)
|
||||
var expectedContent = fs.readFileSync(expectedFileName).toString()
|
||||
var actualContent = fs.readFileSync(tmpFileName).toString()
|
||||
assert.equal(actualContent, expectedContent)
|
||||
fs.rmSync(tmpFileName)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user