| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var fs = require("fs"); | 5 var fs = require("fs"); |
| 6 var http = require("http"); | 6 var http = require("http"); |
| 7 var https = require("https"); | 7 var https = require("https"); |
| 8 var path = require("path"); | 8 var path = require("path"); |
| 9 var parseURL = require("url").parse; | 9 var parseURL = require("url").parse; |
| 10 var shell = require("child_process").execSync; |
| 10 var Stream = require("stream").Transform; | 11 var Stream = require("stream").Transform; |
| 11 | 12 |
| 12 function fetch(url) | 13 function fetch(url) |
| 13 { | 14 { |
| 14 return new Promise(fetchPromise); | 15 return new Promise(fetchPromise); |
| 15 | 16 |
| 16 function fetchPromise(resolve, reject) | 17 function fetchPromise(resolve, reject) |
| 17 { | 18 { |
| 18 var request; | 19 var request; |
| 19 var protocol = parseURL(url).protocol; | 20 var protocol = parseURL(url).protocol; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } catch (error) { | 115 } catch (error) { |
| 115 throw new Error(`Received an error: [${error}] while trying to remove: $
{filePath}`); | 116 throw new Error(`Received an error: [${error}] while trying to remove: $
{filePath}`); |
| 116 } | 117 } |
| 117 } | 118 } |
| 118 | 119 |
| 119 function includes(sequence, target) | 120 function includes(sequence, target) |
| 120 { | 121 { |
| 121 return sequence.indexOf(target) > -1; | 122 return sequence.indexOf(target) > -1; |
| 122 } | 123 } |
| 123 | 124 |
| 125 function shellOutput(command) |
| 126 { |
| 127 return shell(command).toString().trim(); |
| 128 } |
| 129 |
| 124 module.exports = { | 130 module.exports = { |
| 125 fetch, | 131 fetch, |
| 126 atob, | 132 atob, |
| 127 isFile, | 133 isFile, |
| 128 isDir, | 134 isDir, |
| 129 copy, | 135 copy, |
| 130 copyRecursive, | 136 copyRecursive, |
| 131 removeRecursive, | 137 removeRecursive, |
| 132 includes, | 138 includes, |
| 139 shellOutput, |
| 133 }; | 140 }; |
| OLD | NEW |