mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 10:10:08 +02:00
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:
30
services/web/scripts/example/script_for_migration.mjs
Normal file
30
services/web/scripts/example/script_for_migration.mjs
Normal file
@@ -0,0 +1,30 @@
|
||||
/* subscription.freeTrialExpiresAt
|
||||
* Example script for a migration:
|
||||
*
|
||||
* This script demonstrates how to write a script that is runnable either via
|
||||
* the CLI, or via a migration. The related migration is `script_example`
|
||||
* in the migrations directory.
|
||||
*/
|
||||
|
||||
import { User } from '../../app/src/models/User.js'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
// const somePackage = require('some-package')
|
||||
|
||||
const runScript = async () => {
|
||||
const user = await User.findOne({}, { first_name: 1 }).exec()
|
||||
const name = user ? user.first_name : 'World'
|
||||
console.log(`Hello ${name}!`)
|
||||
}
|
||||
|
||||
if (fileURLToPath(import.meta.url) === process.argv[1]) {
|
||||
try {
|
||||
await runScript()
|
||||
process.exit()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
export default runScript
|
||||
Reference in New Issue
Block a user