copy.js 781 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const path = require('path');
  3. const fs = require('fs');
  4. const dest = process.argv[2];
  5. const source = path.resolve(path.sep, process.argv[3] || path.join(__dirname, 'sqlite3'));
  6. const files = [
  7. { filename: 'sqlite3.c', optional: false },
  8. { filename: 'sqlite3.h', optional: false },
  9. ];
  10. if (process.argv[3]) {
  11. // Support "_HAVE_SQLITE_CONFIG_H" in custom builds.
  12. files.push({ filename: 'config.h', optional: true });
  13. } else {
  14. // Required for some tests.
  15. files.push({ filename: 'sqlite3ext.h', optional: false });
  16. }
  17. for (const { filename, optional } of files) {
  18. if (optional && !fs.existsSync(path.join(source, filename))) {
  19. continue;
  20. }
  21. fs.accessSync(path.join(source, filename));
  22. fs.copyFileSync(path.join(source, filename), path.join(dest, filename));
  23. }