Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

wercker template: create directories that do not exist yet

  • Loading branch information...
commit e932084a71701d7e0469c3b0af742976d7e90490 1 parent 0fd4512
wouterm authored
Showing with 28 additions and 2 deletions.
  1. +1 −0  lib/repository.js
  2. +27 −2 lib/wercker.js
View
1  lib/repository.js
@@ -14,6 +14,7 @@ Repository.prototype.readConfig = function(callback) {
'use strict';
var fp = path.resolve('./.git/config');
+
iniparser.parse(fp, function(err, config){
var gitUrl = config['remote "origin"'].url;
var sourceControl ;
View
29 lib/wercker.js
@@ -80,6 +80,19 @@ Wercker.prototype.login= function(callback) {
});
};
+function createDirectoryIfNotExist(fullPath){
+ 'use strict';
+ var dirname = path.dirname(fullPath);
+
+ if(path.existsSync(dirname)){
+ return;
+ }
+ if(!path.existsSync(path.dirname(dirname))){
+ createDirectoryIfNotExist(path.dirname(dirname));
+ }
+ fs.mkdirSync(dirname);
+}
+
Wercker.prototype.template = function(environment) {
'use strict';
var self = this;
@@ -107,9 +120,14 @@ Wercker.prototype.template = function(environment) {
});
},
function(config, next){
+ if(!config){
+ next('No config');
+ }
+ else{
var client = new Client();
client.getTemplates(config.projectName, process.platform, self.token, next);
- },
+ }
+ },
function(result, next){
var i, template, targetFullFileName;
var gitHookDirectory = path.resolve('./.git/hooks');
@@ -130,6 +148,7 @@ Wercker.prototype.template = function(environment) {
console.log(util.format('Ignoring %s because file already exists.', template.fileName));
}
else{
+ createDirectoryIfNotExist(targetFullFileName);
fs.writeFileSync(targetFullFileName, template.content);
console.log(util.format('%s created.', template.fileName));
@@ -175,11 +194,17 @@ Wercker.prototype.create = function(environment) {
});
},
function(config, callback){
+ if(!config){
+ callback('No config');
+ }
+ else{
+
+
var client = new Client();
client.createProject(
config.gitUrl, config.userName, config.projectName, config.sourceControl, environment, self.token, callback
);
-
+ }
},
function(result, callback){
Please sign in to comment.
Something went wrong with that request. Please try again.