This repository has been archived by the owner on Jan 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
339 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ dist: trusty | |
os: | ||
- linux | ||
- osx | ||
- windows | ||
language: node_js | ||
node_js: | ||
- '10.0.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
module.exports = function(grunt) { | ||
|
||
grunt.initConfig({ | ||
download: { | ||
'safe_app-mock': { | ||
url: 'https://s3.eu-west-2.amazonaws.com/safe-client-libs/', | ||
version: '0.9.1', | ||
ext: 'x64.zip' | ||
}, | ||
'system_uri': { | ||
url: 'https://s3.eu-west-2.amazonaws.com/system-uri/', | ||
version: 'v0.4.0', | ||
ext: 'x64.zip' | ||
} | ||
} | ||
}); | ||
|
||
grunt.task.registerMultiTask('download', 'Log stuff.', function() { | ||
let os; | ||
switch (process.platform) { | ||
case 'linux': | ||
os = 'linux'; | ||
break; | ||
case 'win32': | ||
os = 'win'; | ||
break; | ||
case 'darwin': | ||
os = 'osx'; | ||
break; | ||
} | ||
|
||
let url = this.data.url + this.target + '-' + this.data.version + '-' + os + '-' + this.data.ext; | ||
grunt.log.writeln('Downloading native lib for platform ' + os + ', ' + this.target + ' version ' + this.data.version + ' from: ' + url); | ||
|
||
const path = require('path'); | ||
const https = require('https'); | ||
const fs = require('fs'); | ||
|
||
let done = this.async(); | ||
|
||
https.get(url, (res) => { | ||
if (res.statusCode !== 200) { | ||
grunt.log.warn('Got response code ' + res.statusCode + ' while trying to copy ' + url); | ||
} | ||
|
||
//grunt.file.mkdir(path.dirname('download')); | ||
let zipFilePath = this.target + '.zip'; | ||
const wstream = fs.createWriteStream(zipFilePath); | ||
|
||
res.on('data', function(chunk) { | ||
grunt.log.write('+'); | ||
wstream.write(chunk); | ||
}); | ||
|
||
res.on('end', function () { | ||
grunt.log.writeln('Copying....'); | ||
wstream.end(); | ||
grunt.log.writeln('Copied '); | ||
|
||
var extract = require('extract-zip') | ||
let outputPath = path.resolve(__dirname, 'src/native/mock'); | ||
grunt.log.writeln(outputPath); | ||
extract(zipFilePath, { dir: outputPath }, function (err) { | ||
if (err) { | ||
grunt.fail.warn('Got error: ' + err); | ||
done(false); | ||
} | ||
done(); | ||
}) | ||
|
||
}); | ||
|
||
res.on('error', function (e) { | ||
grunt.fail.warn('Got error: ' + e.message); | ||
done(false); | ||
}); | ||
|
||
}).on('error', (e) => { | ||
grunt.fail.warn('Got error: ' + e.message); | ||
}); | ||
|
||
|
||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.