|
| 1 | +/** |
| 2 | + * Copyright 2019 Google LLC. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import * as execa from 'execa'; |
| 18 | +import * as mv from 'mv'; |
| 19 | +import {ncp} from 'ncp'; |
| 20 | +import * as tmp from 'tmp'; |
| 21 | +import {promisify} from 'util'; |
| 22 | + |
| 23 | +const keep = false; |
| 24 | +const mvp = (promisify(mv) as {}) as (...args: string[]) => Promise<void>; |
| 25 | +const ncpp = promisify(ncp); |
| 26 | +const stagingDir = tmp.dirSync({keep, unsafeCleanup: true}); |
| 27 | +const stagingPath = stagingDir.name; |
| 28 | + |
| 29 | +const pkg = require('../../package.json'); |
| 30 | + |
| 31 | +describe('📦 pack and install', () => { |
| 32 | + /** |
| 33 | + * Create a staging directory with temp fixtures used to test on a fresh |
| 34 | + * application. |
| 35 | + */ |
| 36 | + it('should be able to use the d.ts', async () => { |
| 37 | + await execa('npm', ['pack', '--unsafe-perm']); |
| 38 | + const tarball = `google-cloud-bigtable-${pkg.version}.tgz`; |
| 39 | + await mvp(tarball, `${stagingPath}/bigtable.tgz`); |
| 40 | + await ncpp('system-test/fixtures/sample', `${stagingPath}/`); |
| 41 | + await execa('npm', ['install', '--unsafe-perm'], { |
| 42 | + cwd: `${stagingPath}/`, |
| 43 | + stdio: 'inherit', |
| 44 | + }); |
| 45 | + await execa('node', ['--throw-deprecation', 'build/src/index.js'], { |
| 46 | + cwd: `${stagingPath}/`, |
| 47 | + stdio: 'inherit', |
| 48 | + }); |
| 49 | + }); |
| 50 | + |
| 51 | + /** |
| 52 | + * CLEAN UP - remove the staging directory when done. |
| 53 | + */ |
| 54 | + after('cleanup staging', () => { |
| 55 | + if (!keep) { |
| 56 | + stagingDir.removeCallback(); |
| 57 | + } |
| 58 | + }); |
| 59 | +}); |
0 commit comments