Files
configure-pages/src/set-pages-path.js
T

48 lines
1.1 KiB
JavaScript
Raw Normal View History

const core = require('@actions/core')
const axios = require('axios')
2022-06-17 18:36:26 -07:00
const { ConfigParser } = require('./config-parser')
2022-06-17 18:36:26 -07:00
async function setPagesPath({staticSiteGenerator, path}) {
try {
switch(staticSiteGenerator)
{
case 'nuxt':
var ssConfig = {
filePath:"./nuxt.config.js",
type: "nuxt",
pathName: "router",
subPathName: "base",
2022-06-17 18:36:26 -07:00
newPath: path
}
break;
case 'next':
var ssConfig = {
filePath:"./next.config.js",
type: "next",
2022-06-17 15:13:00 -07:00
pathName: "basePath",
2022-06-17 18:36:26 -07:00
newPath: path
}
break;
case 'gatsby':
var ssConfig = {
filePath: "./gatsby-config.js",
type: "gatsby",
pathName: "pathPrefix",
2022-06-17 18:36:26 -07:00
newPath: path
}
break;
default:
throw "Unknown config type"
}
let configParser = new ConfigParser(ssConfig)
2022-06-17 18:36:26 -07:00
configParser.parse()
} catch (error) {
core.error('Set pages path in the static site generator config failed', error)
throw error
}
}
module.exports = setPagesPath