mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
23 lines
679 B
TypeScript
23 lines
679 B
TypeScript
/**
|
|
* Copies a file into every sample, overwriting the existing file if it exists.
|
|
*/
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { lspSamples, samples } from './samples';
|
|
|
|
if (require.main === module) {
|
|
const filePath = process.argv[2];
|
|
if (!filePath) {
|
|
console.error('Please provide a file path as the argument.');
|
|
process.exit(1);
|
|
}
|
|
|
|
const fileName = path.basename(filePath);
|
|
const fileContent = fs.readFileSync(filePath);
|
|
|
|
for (const sample of [...samples, ...lspSamples]) {
|
|
const destinationPath = path.join(sample.path, fileName);
|
|
fs.writeFileSync(destinationPath, fileContent);
|
|
console.log(`Copied ${fileName} to ${sample.path}`);
|
|
}
|
|
} |