Skip to content

Commit

Permalink
Use resolved path for actions-yml (#232) (#233)
Browse files Browse the repository at this point in the history
Co-authored-by: James Forbes <james.a.forbes@gmail.com>
  • Loading branch information
github-actions[bot] and JAForbes authored Jan 8, 2022
1 parent 6c44bb3 commit b8462da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* globals console, process */
import { Buffer } from 'buffer'
import path from 'path'
import { URL } from 'url'
import { chalk, argv as _argv, $, fs } from 'zx'
import dotenv from 'dotenv'
import { Octokit as OriginalOctokit } from 'octokit'
Expand All @@ -10,14 +11,19 @@ import Module from 'module'

let require = Module.createRequire(import.meta.url)
let pkg = require('../package.json')

let Octokit = OriginalOctokit.plugin(throttling)

dotenv.config()
let argv = { ..._argv }
argv.verbose = argv.verbose || argv.v
$.verbose = argv.verbose

let __dirname =
path.dirname(new URL('', import.meta.url).pathname);

let repoPath =
filepath => path.resolve(__dirname, '..', filepath);

/**
* @typedef { import("octokit").Octokit } Octokit
*/
Expand Down Expand Up @@ -251,7 +257,7 @@ async function generateTemplates(){
z=z.replace(/\bmain\b/gm, '$target')
z = z.replace(/(.*)#\s+prr:comment/gm, '#$1')
z = z.replace(/(.*)#\s+prr:remove/gm, '')
await fs.writeFile(`./templates/${x}`, z)
await fs.writeFile(repoPath(`./templates/${x}`), z)
}
}

Expand All @@ -265,7 +271,7 @@ async function actionsYML(){
]

for( let file of templates ) {
let x = await fs.readFile(`./templates/${file}`, 'utf8')
let x = await fs.readFile(repoPath(`./templates/${file}`), 'utf8')
x = x.replace(/\$target/g, target)
x = x.replace(/\$source/g, source)
await fs.writeFile(`./.github/workflows/${file}`, x)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
],
"files": [
"lib/*",
"dist/*"
"dist/*",
"templates/*"
],
"author": "JAForbes",
"license": "MIT",
Expand Down

0 comments on commit b8462da

Please sign in to comment.