mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-11 15:10:48 +02:00
Merge pull request #20731 from overleaf/revert-20480-ls-convert-migration-scripts-to-esm
Revert "Convert migration scripts to ESM" GitOrigin-RevId: ca9ddda6ddee8964f72797d3b653ef9cee6a7a49
This commit is contained in:
@@ -40,7 +40,7 @@ async function updateStringDates() {
|
||||
console.log(`Updated ${count} confirmedAt strings to dates!`)
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
if (!module.parent) {
|
||||
updateStringDates()
|
||||
.then(() => {
|
||||
process.exit(0)
|
||||
|
||||
@@ -15,7 +15,8 @@ const runScript = async () => {
|
||||
console.log(`Hello ${name}!`)
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
if (!module.parent) {
|
||||
// we are in the root module, which means that we're running as a script
|
||||
runScript()
|
||||
.then(() => process.exit())
|
||||
.catch(err => {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import Adapter from '../migrations/lib/adapter.mjs'
|
||||
import { promises as fs } from 'fs'
|
||||
import { join, dirname } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const Adapter = require('../migrations/lib/adapter')
|
||||
const fs = require('fs').promises
|
||||
const path = require('path')
|
||||
|
||||
async function main(args) {
|
||||
if (
|
||||
@@ -14,7 +11,7 @@ async function main(args) {
|
||||
args.includes('-h')
|
||||
) {
|
||||
console.log('')
|
||||
console.log('usage: node ./scripts/mark_migration.mjs migration state')
|
||||
console.log('usage: node ./scripts/mark_migration.js migration state')
|
||||
console.log('')
|
||||
console.log(' migration: name of migration file')
|
||||
console.log(' state: executed | unexecuted')
|
||||
@@ -32,7 +29,7 @@ async function main(args) {
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.access(join(__dirname, '../migrations', `${migration}.mjs`))
|
||||
await fs.access(path.join(__dirname, '../migrations', `${migration}.js`))
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Error: migration ${migration} does not exist on disk: ${err}`
|
||||
@@ -57,7 +54,7 @@ async function main(args) {
|
||||
console.log('Done')
|
||||
}
|
||||
|
||||
if (fileURLToPath(import.meta.url) === process.argv[1]) {
|
||||
if (require.main === module) {
|
||||
const args = process.argv.slice(2)
|
||||
main(args)
|
||||
.then(() => {
|
||||
Reference in New Issue
Block a user