Skip to content

Commit

Permalink
fix: Revert es module (electron#1873)
Browse files Browse the repository at this point in the history
* chore: fix ci & tests

* Revert "chore: update to es module (electron#1869)"

This reverts commit db9a401.

* Revert "chore: fix ci & tests (electron#1870)"

This reverts commit ecb88ce.
  • Loading branch information
Toinane authored Aug 26, 2021
1 parent 737006d commit 2855ab5
Show file tree
Hide file tree
Showing 31 changed files with 646 additions and 8,982 deletions.
10 changes: 1 addition & 9 deletions categories.js
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
import fs from 'fs'
import path from 'path'
import { _dirname } from './lib/dirname.js'

const categories = JSON.parse(
fs.readFileSync(path.join(_dirname(import.meta), './meta/categories.json'))
)

export default categories
module.exports = require('./meta/categories.json')
2 changes: 1 addition & 1 deletion lib/app-categories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default [
module.exports = [
'Books',
'Business',
'Catalogs',
Expand Down
6 changes: 3 additions & 3 deletions lib/apps-with-github-repos.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import apps from './raw-app-list.js'
import parseGitUrl from 'github-url-to-object'
const apps = require('./raw-app-list')()
const parseGitUrl = require('github-url-to-object')

export default apps.filter((app) => {
module.exports = apps.filter((app) => {
// inherit repository from website if possible
if (!app.repository && parseGitUrl(app.website)) app.repository = app.website
if (!app.repository) return false
Expand Down
19 changes: 9 additions & 10 deletions lib/broken-links.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import fetch from 'node-fetch'
import fs from 'fs'
import isUrl from 'is-url'
import path from 'path'
import readdirp from 'readdirp'
import yaml from 'yaml'
import { _dirname } from './dirname.js'
const fetch = require('node-fetch')
const fsPromises = require('fs').promises
const isUrl = require('is-url')
const path = require('path')
const readdirp = require('readdirp')
const yaml = require('yaml')

const topDir = path.dirname(_dirname(import.meta))
const topDir = path.dirname(__dirname)

// walk an object subtree looking for URL strings
const getObjectUrls = (root) => {
Expand Down Expand Up @@ -37,7 +36,7 @@ const scrape = (url) =>
// report broken links to console.log().
// return a Promise that resolves as an array of broken links: [ { url, err }, ... ]
const processYmlEntry = (entry) =>
fs
fsPromises
.readFile(entry.fullPath, { encoding: 'utf8' })
.then((file) => {
try {
Expand Down Expand Up @@ -91,4 +90,4 @@ const findBrokenLinks = (start = 0, end = Infinity) =>
})
.then((arr) => arr.filter((inner) => !!inner.result.length))

export default findBrokenLinks
module.exports = findBrokenLinks
24 changes: 12 additions & 12 deletions lib/colors.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'

import fs from 'fs'
import colorConvert from 'color-convert'
import getImageColors from 'get-image-colors'
import mime from 'mime-types'
import path from 'path'
import pickAGoodColor from 'pick-a-good-color'
import revHash from 'rev-hash'
import stringify from 'json-stable-stringify'
const fs = require('fs')
const colorConvert = require('color-convert')
const getImageColors = require('get-image-colors')
const mime = require('mime-types')
const path = require('path')
const pickAGoodColor = require('pick-a-good-color')
const revHash = require('rev-hash')
const stringify = require('json-stable-stringify')

/**
* Generates good colors for an image.
Expand Down Expand Up @@ -69,10 +69,10 @@ async function getColors(slugsAndIconPaths, oldColors, root) {
* @param colorsFile: the file that keeps the list of complimentary colors
* @param root: repo toplevel directory so that saved iconPaths are relative to it
*/
const rebuildColorFile = async (slugsAndIconPaths, colorsFile, root) => {
const rebuildColorFile = (slugsAndIconPaths, colorsFile, root) => {
let oldColors
try {
oldColors = await import(colorsFile)
oldColors = require(colorsFile)
} catch (e) {
oldColors = {}
}
Expand All @@ -86,5 +86,5 @@ const rebuildColorFile = async (slugsAndIconPaths, colorsFile, root) => {
})
}

export default rebuildColorFile
export { getColors }
module.exports = rebuildColorFile
module.exports.getColors = getColors
6 changes: 0 additions & 6 deletions lib/dirname.js

This file was deleted.

6 changes: 3 additions & 3 deletions lib/github.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if (!process.env.GH_TOKEN) {
await import('dotenv-safe/config.js')
require('dotenv-safe').config()
}

import { Octokit } from '@octokit/rest'
const { Octokit } = require('@octokit/rest')
const github = new Octokit({
auth: process.env.GH_TOKEN,
})

export default github
module.exports = github
2 changes: 1 addition & 1 deletion lib/grandfathered-descriptions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Apps in this list were submitted before tests were added
// to enforce the submission guidelines for descriptions
export default [
module.exports = [
'1clipboard',
'5eclient',
'aalarm',
Expand Down
2 changes: 1 addition & 1 deletion lib/grandfathered-links.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Apps in this list were submitted before tests were added
// to enforce the submission guidelines for links
export default [
module.exports = [
'1clipboard',
'autobeat-player',
'backlog',
Expand Down
2 changes: 1 addition & 1 deletion lib/grandfathered-small-icons.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Apps in this list were submitted before we bumped the minimum
// icon dimension from 128 to 256.

export default [
module.exports = [
'airtame',
'aiting',
'ansel',
Expand Down
19 changes: 9 additions & 10 deletions lib/old-electron-apps.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import fetch from 'node-fetch'
import fs from 'fs'
import isUrl from 'is-url'
import path from 'path'
import readdirp from 'readdirp'
import yaml from 'yaml'
import { _dirname } from './dirname.js'
const fetch = require('node-fetch')
const fsPromises = require('fs').promises
const isUrl = require('is-url')
const path = require('path')
const readdirp = require('readdirp')
const yaml = require('yaml')

const topDir = path.dirname(_dirname(import.meta))
const topDir = path.dirname(__dirname)

// walk an object subtree looking for URL strings
const getObjectUrls = (root) => {
Expand Down Expand Up @@ -53,7 +52,7 @@ const scrape = (url) => {
// report broken links to console.log().
// return a Promise that resolves as an array of broken links: [ { url, err }, ... ]
const processYmlEntry = (entry) =>
fs
fsPromises
.readFile(entry.fullPath, { encoding: 'utf8' })
.then((file) => {
try {
Expand Down Expand Up @@ -97,4 +96,4 @@ const findOldElectronApps = (start = 0, end = Infinity) =>
return result
})

export default findOldElectronApps
module.exports = findOldElectronApps
58 changes: 27 additions & 31 deletions lib/raw-app-list.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
import fs from 'fs'
import yaml from 'js-yaml'
import path from 'path'
import { _dirname } from './dirname.js'
const fs = require('fs')
const path = require('path')
const yaml = require('js-yaml')

export default fs
.readdirSync(path.join(_dirname(import.meta), '../apps'))
.filter((filename) => {
return fs
.statSync(path.join(_dirname(import.meta), `../apps/${filename}`))
.isDirectory()
})
.sort()
.reduce((slugs, slug) => {
const yamlFile = path.join(
_dirname(import.meta),
`../apps/${slug}/${slug}.yml`
)
const meta = yaml.load(fs.readFileSync(yamlFile))
module.exports = function getSlugs() {
return fs
.readdirSync(path.join(__dirname, '../apps'))
.filter((filename) => {
return fs
.statSync(path.join(__dirname, `../apps/${filename}`))
.isDirectory()
})
.sort()
.reduce((slugs, slug) => {
const yamlFile = path.join(__dirname, `../apps/${slug}/${slug}.yml`)
const meta = yaml.load(fs.readFileSync(yamlFile))

if (meta.disabled) {
return slugs
} else {
const app = {
slug: slug,
iconPath: path.join(
_dirname(import.meta),
`../apps/${slug}/${slug}-icon.png`
),
...meta,
if (meta.disabled) {
return slugs
} else {
const app = {
slug: slug,
iconPath: path.join(__dirname, `../apps/${slug}/${slug}-icon.png`),
...meta
}
return [...slugs, app]
}
return [...slugs, app]
}
}, [])

}, [])
}
Loading

0 comments on commit 2855ab5

Please sign in to comment.