@appshuttle.io/turing
Version:
Code Generation Library used in Shuttle
54 lines (40 loc) • 1.65 kB
JavaScript
const fs = require('fs')
const PBXPROJMotor = require('./GenerationMotors/PBXPROJ-Motor')
class iOSMainProjectGenerator {
constructor(path, project, screenPointers, screens) {
if (!path) throw new Error('No pbxproj path is specified')
if (!project) throw new Error('No project is specified')
if (!screenPointers) throw new Error('No screen pointers were specified')
if (!screens) throw new Error('No screens were specified')
this.path = path
this.project = project
this.screenPointers = screenPointers
this.screens = screens
this.pbxprojMotor = new PBXPROJMotor(path + '/project.pbxproj', project, screenPointers, screens)
this.generateMainProject = function () {
try {
if (!fs.existsSync(this.path)){
fs.mkdirSync(this.path);
}
} catch (err) {
return
}
var generatePromises = []
generatePromises.push(this.pbxprojMotor.generatePBXPROJ())
const context = this
return new Promise((resolve, reject) => {
Promise.all(generatePromises).then(function (values) {
try {
fs.renameSync(context.path, context.path.replace('_xcodeproj', '.xcodeproj'))
resolve()
} catch (error) {
reject(error)
}
}).catch(function (error) {
reject(error)
})
})
}
}
}
module.exports = iOSMainProjectGenerator