From 596446835a16dfd1dce963944ac193071fb66796 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 11 Dec 2014 16:00:24 -0400 Subject: [PATCH] Reimplement app init with resin.vcs --- lib/actions/app.coffee | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/actions/app.coffee b/lib/actions/app.coffee index 0a09731f..98becbb8 100644 --- a/lib/actions/app.coffee +++ b/lib/actions/app.coffee @@ -63,15 +63,24 @@ exports.remove = (id) -> exports.init = (id) -> + currentDirectory = process.cwd() + async.waterfall [ + (callback) -> + resin.vcs.wasInitialized(currentDirectory, callback) + + (wasInitialized, callback) -> + if wasInitialized + error = new Error('Project is already a resin application.') + return callback(error) + return callback() + (callback) -> resin.models.application.get(id, callback) (application, callback) -> - path = require('path') - repository = new gitCli.Repository(path.join(process.cwd(), '.git')) - repository.addRemote('resin', application.git_repository, callback) + resin.vcs.initApplication(application, currentDirectory, callback) ], (error) -> resin.errors.handle(error) if error?