Merge pull request #21202 from overleaf/ls-scripts-to-esm-2

Migrate scripts folder to esm 2/x

GitOrigin-RevId: 1698bc4f13e026fa281d37a4914a2f997849c761
This commit is contained in:
Liangjun Song
2024-10-22 09:21:39 +01:00
committed by Copybot
parent f2ec640b06
commit 902ae750dc
21 changed files with 184 additions and 184 deletions

View File

@@ -6,7 +6,9 @@
* in the migrations directory.
*/
const { User } = require('../../app/src/models/User')
import { User } from '../../app/src/models/User.js'
import { fileURLToPath } from 'url'
// const somePackage = require('some-package')
const runScript = async () => {
@@ -15,13 +17,14 @@ const runScript = async () => {
console.log(`Hello ${name}!`)
}
if (require.main === module) {
runScript()
.then(() => process.exit())
.catch(err => {
console.error(err)
process.exit(1)
})
if (fileURLToPath(import.meta.url) === process.argv[1]) {
try {
await runScript()
process.exit()
} catch (error) {
console.error(error)
process.exit(1)
}
}
module.exports = runScript
export default runScript