Skip to content

Commit

Permalink
Update download status message (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-boyd authored Jan 21, 2018
1 parent fc6b99a commit be60828
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"install": "cd server && npm install && cd ../client && npm install",
"build":"npm run build:client && npm run build:server",
"build": "npm run build:client && npm run build:server",
"build:client": "cd client && npm run build",
"build:server": "cd server && npm run build",
"watch:client": "cd server && npm run build && cd ../client && npm run watch",
Expand Down
13 changes: 4 additions & 9 deletions server/src/TSQLLintToolsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,12 @@ export default class TSQLLintRuntimeHelper {
}

private UnzipRuntime(path: string, tsqllintInstallDirectory: string) {
console.log('ONE')

return new Promise((resolve, reject) => {
decompress(path, `${tsqllintInstallDirectory}`, {
plugins: [
decompressTargz()
]
}).then(() => {
console.log('TWO')
TSQLLintRuntimeHelper._tsqllintToolsPath = tsqllintInstallDirectory;
return resolve(tsqllintInstallDirectory);
}).catch((err: Error) => {
Expand All @@ -82,16 +79,15 @@ export default class TSQLLintRuntimeHelper {
let downloadPath: string = `${installDirectory}/${TSQLLintRuntimeHelper._runTime}.tgz`

return new Promise((resolve, reject) => {
console.log('Installing TSQLLint Runtime');
console.log(`Installing TSQLLint Runtime: ${downloadUrl}`);
if (!fs.existsSync(installDirectory)) {
fs.mkdirSync(installDirectory);
}
var file = fs.createWriteStream(downloadFilePath)
var request = https.get(downloadUrl, (response: any) => {
const length = Number(response.headers['content-length']);
response.pipe(file)

process.stdout.write('downloading...');
process.stdout.write('Downloading...');

if (!isNaN(length)) {
process.stdout.write(' [');
Expand All @@ -104,16 +100,15 @@ export default class TSQLLintRuntimeHelper {
for (let i = char; i < fill; i++) process.stdout.write('=');
char = fill;
});
response.on('end', () => process.stdout.write(']'));
response.on('end', () => process.stdout.write(']\n'));
}
file.on('finish', function () {
console.log(' done!');
file.close(resolve(downloadPath))
});
}).on('response', (res: any) => {
if (res.statusCode != 200) {
fs.unlink(downloadPath)
return reject(new Error(`There was a problem downloading ${downloadUrl}`))
return reject(new Error(`There was a problem downloading the TSQLLint Runtime. Reload VS Code to try again`))
}
}).on('error', function (err: Error) {
fs.unlink(downloadPath)
Expand Down

0 comments on commit be60828

Please sign in to comment.