2020-11-23 20:45:01 +00:00
|
|
|
import { promisify } from 'util'
|
|
|
|
import childProcessPromise from 'child-process-promise'
|
|
|
|
import path from 'path'
|
|
|
|
import fs from 'fs'
|
2021-01-25 02:26:40 +00:00
|
|
|
import { envFile, RUBY_VERSION } from './mastodon-config'
|
2020-11-23 20:45:01 +00:00
|
|
|
|
|
|
|
const exec = childProcessPromise.exec
|
|
|
|
const stat = promisify(fs.stat)
|
|
|
|
const writeFile = promisify(fs.writeFile)
|
|
|
|
const dir = __dirname
|
|
|
|
|
2021-04-02 18:13:25 +01:00
|
|
|
const GIT_URL = 'https://github.com/nolanlawson/mastodon.git'
|
|
|
|
const GIT_TAG = 'tag-abad99f'
|
2020-11-23 20:45:01 +00:00
|
|
|
|
|
|
|
const mastodonDir = path.join(dir, '../mastodon')
|
|
|
|
|
|
|
|
export default async function cloneMastodon () {
|
|
|
|
try {
|
|
|
|
await stat(mastodonDir)
|
|
|
|
} catch (e) {
|
|
|
|
console.log('Cloning mastodon...')
|
2020-11-24 00:29:03 +00:00
|
|
|
await exec(`git clone --single-branch --branch ${GIT_TAG} ${GIT_URL} "${mastodonDir}"`)
|
2020-11-23 20:45:01 +00:00
|
|
|
await writeFile(path.join(dir, '../mastodon/.env'), envFile, 'utf8')
|
2021-01-25 02:26:40 +00:00
|
|
|
await writeFile(path.join(dir, '../mastodon/.ruby-version'), RUBY_VERSION, 'utf8')
|
2020-11-23 20:45:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (require.main === module) {
|
|
|
|
cloneMastodon().catch(err => {
|
|
|
|
console.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
|
|
|
}
|