Skip to content

Commit

Permalink
fix(build): GitHub actions do not support ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Oct 8, 2021
1 parent 0e8748b commit f896644
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -9,4 +9,4 @@ inputs:

runs:
using: 'node12'
main: 'dist/index.mjs'
main: 'dist/index.js'
16 changes: 6 additions & 10 deletions index.mjs → index.js
@@ -1,21 +1,17 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import * as fs from 'fs'
import { parser } from '@conventional-commits/parser'
import { visit } from 'unist-util-visit'
const core = require('@actions/core')
const github = require('@actions/github')
const fs = require('fs')
const { readFile } = fs.promises
const { parser } = require('@conventional-commits/parser')

const api = {
const api = module.exports = {
addLabel,
isPullRequest,
main
}

export {
api
}

async function main () {
const { visit } = await import('unist-util-visit')
if (!process.env.GITHUB_EVENT_PATH) {
console.warn('no event payload found')
return
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -3,12 +3,12 @@
"private": true,
"version": "1.0.3",
"description": "automatically apply release labels to PR, based on conventionalcommits.org",
"main": "index.mjs",
"main": "index.js",
"scripts": {
"test": "c8 mocha test/*.mjs",
"test": "c8 mocha test/*.js",
"posttest": "standard",
"fix": "standard --fix",
"build": "ncc build index.mjs"
"build": "ncc build index.js"
},
"repository": {
"type": "git",
Expand Down
@@ -1,8 +1,8 @@
import { describe, it, afterEach } from 'mocha'
import { api } from '../index.mjs'
const { describe, it, afterEach } = require('mocha')
const api = require('../index.js')
// import * as assert from 'assert'
// import * as core from '@actions/core'
import sinon from 'sinon'
const sinon = require('sinon')

const sandbox = sinon.createSandbox()
process.env.GITHUB_EVENT_PATH = process.env.GITHUB_EVENT_PATH || ''
Expand Down

0 comments on commit f896644

Please sign in to comment.