-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5ec1b5
commit b8e1411
Showing
3 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
try { | ||
|
||
/** | ||
* Script to run after npm install | ||
* | ||
* Copy selected files to user's directory | ||
*/ | ||
const script_prefix= 'oidc-client'; | ||
|
||
const copyFile = async (src, dest, overwrite) => { | ||
if(!fileExists(src)) { | ||
console.log(`[${script_prefix}:skip] file does not exist ${src}`); | ||
return false; | ||
} | ||
if (!overwrite) { | ||
if (fileExists(dest)) { | ||
console.log(`[${script_prefix}:skip] file exists not overwriting ${dest}`); | ||
return true; | ||
} | ||
} | ||
await fs.promises.copyFile(src, dest); | ||
console.log(`[${script_prefix}:copy] ${dest}`); | ||
return false | ||
}; | ||
|
||
const fileExists = (path) => { | ||
return !!fs.existsSync(path); | ||
}; | ||
|
||
const initPath = process.cwd(); | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const srcDir = path.join(__dirname, "public"); | ||
const destinationFolder = process.argv.length >= 3 ? process.argv[2] : 'public'; | ||
const destinationDir = path.join(initPath, destinationFolder); | ||
|
||
const files = [ | ||
{ | ||
fileName: 'opencv.js', | ||
overwrite: true, | ||
}, | ||
]; | ||
|
||
for await (const file of files) { | ||
await copyFile( | ||
path.join(srcDir, file.fileName), | ||
path.join(destinationDir, file.fileName), | ||
file.overwrite | ||
); | ||
} | ||
|
||
} catch (err) { | ||
console.warn(err); | ||
} |