Skip to content

Commit 4e21fcc

Browse files
committed
Initial creation
1 parent 6923b7f commit 4e21fcc

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

index.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/*eslint-env node*/
22
'use strict';
33

4+
const glob = require('glob');
5+
const detectInstalled = require('detect-installed');
6+
const util = require('util');
7+
const path = require('path');
8+
const execFile = util.promisify(require('child_process').execFile);
9+
410
//const RSVP = require('rsvp');
511
const DeployPluginBase = require('ember-cli-deploy-plugin');
612

@@ -28,9 +34,12 @@ module.exports = {
2834
* http://ember-cli-deploy.com/docs/v1.0.x/pipeline-hooks/
2935
*/
3036

31-
//configure(context) {
32-
// let configProp = this.readConfig('foo'); // this is how you access plugin config
33-
//},
37+
configure(context) {
38+
var claspInstalled = detectInstalled.sync('clasp');
39+
if (!claspInstalled) {
40+
throw new Error('@google/clasp must be installed and you must be logged in');
41+
}
42+
},
3443

3544
//setup(context) {
3645
// // Return an object with values you'd like merged in to the context to be accessed by other pipeline hooks and plugins
@@ -52,7 +61,20 @@ module.exports = {
5261
//didPrepare(context) {},
5362

5463
//willUpload(context) {},
55-
//upload(context) {},
64+
upload(/*context*/) {
65+
var distDir = this.readConfig('distDir');
66+
var claspConfigFiles = glob.sync(`${distDir}/**/.clasp.json`);
67+
var promises = [];
68+
claspConfigFiles.forEach((configFile) => {
69+
var claspProjectDir = path.dirname(configFile);
70+
process.chdir(claspProjectDir);
71+
var claspPromise = execFile('clasp', 'push').then(({ stdout }/*, stderr*/) => {
72+
this.log(stdout);
73+
});
74+
promises.push(claspPromise);
75+
});
76+
return Promise.all(promises);
77+
},
5678
//didUpload(context) {},
5779

5880
//willActivate(context) {},

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"author": "",
1717
"license": "MIT",
1818
"dependencies": {
19+
"detect-installed": "^2.0.4",
1920
"ember-cli-deploy-plugin": "^0.2.9",
2021
"rsvp": "^3.5.0"
2122
},

0 commit comments

Comments
 (0)