aws-sdk 2.288.0 → 2.292.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/core.js CHANGED
@@ -20,7 +20,7 @@ AWS.util.update(AWS, {
20
20
  /**
21
21
  * @constant
22
22
  */
23
- VERSION: '2.288.0',
23
+ VERSION: '2.292.0',
24
24
 
25
25
  /**
26
26
  * @api private
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aws-sdk",
3
3
  "description": "AWS SDK for JavaScript",
4
- "version": "2.288.0",
4
+ "version": "2.292.0",
5
5
  "author": {
6
6
  "name": "Amazon Web Services",
7
7
  "email": "",
@@ -121,7 +121,7 @@
121
121
  "waf"
122
122
  ],
123
123
  "scripts": {
124
- "test": "npm -s run-script lint && npm -s run-script unit && npm -s run-script buildertest && npm -s run-script browsertest && npm -s run-script react-native-test && npm -s run-script tstest && ([ -f configuration ] && npm -s run-script integration || true)",
124
+ "test": "node ./scripts/composite-test.js && ([ -f configuration ] && npm -s run-script integration || true)",
125
125
  "unit": "mocha -- test test/json test/model test/protocol test/query test/services test/signers test/xml test/s3 test/cloudfront test/dynamodb test/polly test/rds test/event-stream",
126
126
  "coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --reporter=lcovonly -- test test/json test/model test/protocol test/query test/services test/signers test/xml test/s3 test/cloudfront test/dynamodb test/polly test/rds test/event-stream",
127
127
  "browsertest": "rake browser:test && karma start",
@@ -140,6 +140,7 @@
140
140
  "react-native-test": "npm -s run-script build-react-native && rake reactnative:test && karma start",
141
141
  "region-check": "node ./scripts/region-checker/index.js",
142
142
  "translate-api-test": "mocha scripts/lib/translate-api.spec.js",
143
- "typings-generator-test": "mocha scripts/lib/prune-shapes.spec.js"
143
+ "typings-generator-test": "mocha scripts/lib/prune-shapes.spec.js",
144
+ "helper-test": "mocha scripts/lib/test-helper.spec.js"
144
145
  }
145
146
  }
@@ -0,0 +1,36 @@
1
+ const {execute, executeLongProcess} = require('./lib/test-helper');
2
+
3
+ async function run() {
4
+ const EXEC = {
5
+ 'execute': execute,
6
+ 'executeLongProcess': executeLongProcess,
7
+ }
8
+ const scripts = [
9
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'helper-test'], retryCount: 1 },
10
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'lint']},
11
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'unit'] },
12
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'buildertest'] },
13
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'tstest'] },
14
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'region-check'] },
15
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'translate-api-test'] },
16
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'typings-generator-test'] },
17
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'browsertest'] },
18
+ { execute: 'executeLongProcess', command: ['npm', 'run', 'react-native-test'] },
19
+ ];
20
+ for (const { execute, command, execOptions, retryCount } of scripts) {
21
+ try {
22
+ await EXEC[execute](command, execOptions, retryCount);
23
+ } catch (error) {
24
+ throw error;
25
+ }
26
+ }
27
+ }
28
+
29
+ (async () => {
30
+ try {
31
+ await run();
32
+ } catch (e) {
33
+ console.log(e);
34
+ process.exit(1);
35
+ }
36
+ })();
@@ -0,0 +1,85 @@
1
+ const { exec, spawn } = require('child_process');
2
+
3
+ /**
4
+ * wrap child_process.exec with retry. Will throw immediately when return
5
+ * code not 0; Used for trivial commands since error detail won't be printed.
6
+ * @param {string} command
7
+ * @param {structure} execOptoins
8
+ * @param {number} retryCount
9
+ */
10
+ async function executeCommand(command, execOptoins = {}, retryCount = 1) {
11
+ try {
12
+ const execCommand = command.join(' ');
13
+ const { stderr, stdout } = await execute(execCommand, execOptoins);
14
+ if (stderr) process.stderr.write(stderr.toString());
15
+ if (stdout) process.stderr.write(stdout.toString());
16
+ } catch (error) {
17
+ if (retryCount > 0) {
18
+ await executeCommand(command, execOptoins, --retryCount);
19
+ } else {
20
+ throw error;
21
+ }
22
+ }
23
+ }
24
+
25
+ function execute(command, options) {
26
+ return new Promise((resolve, reject) => {
27
+ exec(command, options, (err, stdout, stderr) => {
28
+ if (err) {
29
+ reject(err);
30
+ } else {
31
+ resolve({
32
+ stdout: stdout,
33
+ stderr: stderr
34
+ });
35
+ }
36
+ });
37
+ })
38
+ }
39
+
40
+ /**
41
+ * wrap child_process.spawn with retry
42
+ * @param {string} command
43
+ * @param {structure} execOptions
44
+ * @param {number} retryCount
45
+ */
46
+ async function executeLongProcessCommand(command, execOptions = {}, retryCount = 1) {
47
+ try {
48
+ const firstCommand = command[0];
49
+ const options = command.slice(1);
50
+ await promisifiedSpawn(firstCommand, options, execOptions);
51
+ } catch (error) {
52
+ if (retryCount > 0) {
53
+ await executeLongProcessCommand(command, execOptions, --retryCount);
54
+ } else {
55
+ throw error;
56
+ }
57
+ }
58
+ }
59
+
60
+ function promisifiedSpawn(command, options, execOptions) {
61
+ return new Promise((resolve, reject) => {
62
+ const subProcess = spawn(command, options, execOptions);
63
+ subProcess.stdout.on('data', (data) => {
64
+ process.stdout.write(data.toString());
65
+ });
66
+ subProcess.stderr.on('data', (data) => {
67
+ process.stderr.write(data.toString());
68
+ });
69
+ subProcess.on('error', (err) => {
70
+ console.error('spawn error: ', err);
71
+ });
72
+ subProcess.on('close', (code) => {
73
+ if (code === 0) {
74
+ resolve();
75
+ } else {
76
+ reject(`"${command} ${options.join(' ')}" exited with code: ${code}`);
77
+ }
78
+ });
79
+ });
80
+ }
81
+
82
+ module.exports = {
83
+ execute: executeCommand,
84
+ executeLongProcess: executeLongProcessCommand,
85
+ }
@@ -0,0 +1,51 @@
1
+ const {execute, executeLongProcess} = require('./test-helper');
2
+ const {expect} = require('chai');
3
+
4
+ describe('execute command', (done) => {
5
+ it('doesn\'t retry if succeed', async() => {
6
+ let error;
7
+ try {
8
+ await execute(['exit 0'], {}, 2);
9
+ } catch (e) {
10
+ error = e;
11
+ } finally {
12
+ expect(error).eql(undefined);
13
+ }
14
+ });
15
+
16
+ it('can retry command', async () => {
17
+ let error;
18
+ try {
19
+ await execute(['exit 1'], {}, 2);
20
+ } catch (e) {
21
+ error = e;
22
+ } finally {
23
+ expect(error).not.undefined;
24
+ expect(typeof error.message).eql('string');
25
+ }
26
+ })
27
+ });
28
+
29
+ describe('executeLongProcess command', (done) => {
30
+ it('doesn\'t retry if succeed', async() => {
31
+ let error;
32
+ try {
33
+ await executeLongProcess(['exit 0'], {shell: true}, 2);
34
+ } catch (e) {
35
+ error = e;
36
+ } finally {
37
+ expect(error).eql(undefined);
38
+ }
39
+ });
40
+
41
+ it('can retry command', async () => {
42
+ let error;
43
+ try {
44
+ await executeLongProcess(['echo \'a\' && exit 1'], {shell: true}, 2);
45
+ } catch (e) {
46
+ error = e;
47
+ } finally {
48
+ expect(error).not.undefined;
49
+ }
50
+ })
51
+ });