diff --git a/package.json b/package.json index c5b177cb1..b6465b292 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@grpc/grpc-js": "~1.8.0", "@grpc/proto-loader": "^0.7.0", "@types/long": "^4.0.0", + "@types/rimraf": "^3.0.2", "abort-controller": "^3.0.0", "duplexify": "^4.0.0", "fast-text-encoding": "^1.0.3", @@ -32,7 +33,7 @@ }, "devDependencies": { "@compodoc/compodoc": "1.1.19", - "@types/fs-extra": "^9.0.0", + "@types/mkdirp": "^1.0.2", "@types/mocha": "^9.0.0", "@types/ncp": "^2.0.1", "@types/node": "^18.0.0", @@ -40,13 +41,11 @@ "@types/object-hash": "^3.0.0", "@types/proxyquire": "^1.3.28", "@types/pumpify": "^1.4.1", - "@types/rimraf": "^3.0.0", "@types/sinon": "^10.0.0", "@types/uglify-js": "^3.17.0", "c8": "^7.0.0", "codecov": "^3.1.0", "execa": "^5.0.0", - "fs-extra": "^10.0.0", "google-proto-files": "^3.0.0", "gts": "^3.1.0", "linkinator": "^4.0.0", diff --git a/test/system-test/test.clientlibs.ts b/test/system-test/test.clientlibs.ts index b050115a6..efe822b80 100644 --- a/test/system-test/test.clientlibs.ts +++ b/test/system-test/test.clientlibs.ts @@ -21,8 +21,8 @@ import * as rimraf from 'rimraf'; import * as util from 'util'; import {describe, it, before} from 'mocha'; -const mkdir = util.promisify(fs.mkdir); const rmrf = util.promisify(rimraf); +const mkdir = util.promisify(fs.mkdir); const readFile = util.promisify(fs.readFile); const writeFile = util.promisify(fs.writeFile); diff --git a/test/unit/minify.ts b/test/unit/minify.ts index eea8e0b9a..80ae14df3 100644 --- a/test/unit/minify.ts +++ b/test/unit/minify.ts @@ -18,10 +18,10 @@ import * as fs from 'fs'; import {promises as fsp} from 'fs'; import * as rimraf from 'rimraf'; import * as path from 'path'; -import * as util from 'util'; import * as minify from '../../tools/minify'; +import {promisify} from 'util'; -const rmrf = util.promisify(rimraf); +const rmrf = promisify(rimraf); const testDir = path.join(process.cwd(), '.minify-test'); const fixturesDir = path.join(__dirname, '..', 'fixtures'); diff --git a/tools/prepublish.ts b/tools/prepublish.ts index b7a91b113..b4b350609 100644 --- a/tools/prepublish.ts +++ b/tools/prepublish.ts @@ -14,9 +14,17 @@ * limitations under the License. */ -import * as fs from 'fs-extra'; import {getProtoPath} from 'google-proto-files'; import * as path from 'path'; +// Note: the following three imports will be all gone when we support Node.js 16+. +// But until then, we'll use these modules. +import * as rimraf from 'rimraf'; +import * as mkdirp from 'mkdirp'; +import * as ncp from 'ncp'; +import {promisify} from 'util'; + +const ncpp = promisify(ncp); +const rmrf = promisify(rimraf); const subdirs = [ 'api', @@ -31,14 +39,17 @@ const subdirs = [ ]; async function main() { - await fs.remove(path.join('protos', 'google')); - await fs.ensureDir(path.join('protos', 'google')); + await rmrf(path.join('protos', 'google')); + await mkdirp(path.join('protos', 'google')); - subdirs.forEach(async subdir => { + for (const subdir of subdirs) { const src = getProtoPath(subdir); const target = path.join('protos', 'google', subdir); - await fs.copy(src, target); - }); + console.log(`Copying protos from ${src} to ${target}`); + await mkdirp(target); + await ncpp(src, target); + } + console.log('Protos have been copied successfully'); } main().catch(console.error);