Skip to content

Commit 33d7038

Browse files
committed
start project from local directory
1 parent 0d36d48 commit 33d7038

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### 1.2.4
22

33
* Use `cross-spawn` module to fix errors with using spawn on Windows
4+
* Start ionic projects using a local directory
45
* Use specific npm versions in package.json to avoid any future errors from breaking changes
56

67

lib/ionic/start.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,19 @@ IonicTask.prototype.fetchWrapper = function() {
149149

150150
IonicTask.prototype.fetchSeed = function() {
151151

152+
// Codepen: http://codepen.io/ionic/pen/GpCst
152153
if(this.template.toLowerCase().indexOf('codepen') > -1) {
153154
this.seedType = 'codepen';
154155
return this.fetchCodepen();
155156
}
156157

158+
// Local Directory: /User/starterapp
159+
if( this.template.indexOf('/') > -1 || this.template.indexOf('\\') > -1 ) {
160+
this.seedType = 'local';
161+
return this.fetchLocalStarter();
162+
}
163+
164+
// Ionic Github Repo
157165
this.seedType = 'ionic-starter';
158166
return this.fetchIonicStarter();
159167
};
@@ -282,6 +290,37 @@ IonicTask.prototype.convertTemplates = function(html) {
282290
};
283291

284292

293+
IonicTask.prototype.fetchLocalStarter = function() {
294+
var self = this;
295+
var q = Q.defer();
296+
297+
try {
298+
cd('..');
299+
300+
var localStarterPath = path.resolve(this.template);
301+
302+
if( !fs.existsSync(localStarterPath) ) {
303+
self.ionic.fail('Unable to find local starter template: ' + localStarterPath);
304+
q.reject();
305+
return q.promise;
306+
}
307+
308+
console.log('\nCopying files to www from:'.bold, localStarterPath);
309+
310+
// Move the content of this repo into the www folder
311+
cp('-Rf', path.join(localStarterPath, '*'), path.join(self.targetPath, 'www'));
312+
313+
q.resolve();
314+
} catch(e) {
315+
q.reject(e);
316+
}
317+
318+
cd(self.targetPath);
319+
320+
return q.promise;
321+
};
322+
323+
285324
IonicTask.prototype.fetchIonicStarter = function() {
286325
var self = this;
287326
var q = Q.defer();

0 commit comments

Comments
 (0)