temject.copy
v0.1.0
Published
Copy the file while converting with temject
Downloads
5
Maintainers
Readme
temject.copy
Copy the file while converting with temject
| function | temject | temjectCopy | | -------------------- | ------- | ----------- | | temject | ⭕ | ⭕ | | keyValueInjector | ⭕ | ⭕ | | dateTimeInjector | ⭕ | ⭕ | | expressions | ⭕ | ⭕ | | expressionFiles | ✘ | ⭕ | | temjectCopy | ✘ | ⭕ | | temjectCopyRecursive | ✘ | ⭕ |
API
expressionFiles(glob [,opts])
| Param | Type | Default | Description | | ------ | ----------------------------------------- | --------------- | ----------------------------------------------------------- | | glob | Array | string | | paths or glob | | [opts] | Object | {} | fast-glob |
await expressionFiles('./testFiles/')
// -> ['foo','bar']
await expressionFiles(
['./testFiles/', '!**/ignore.txt'],
{ dot: false }
)
temjectCopy(srcPath, distPath, injections [, opts])
| Param | Type | Default | Description | | ---------------- | -------------------- | ------------------ | -------------------- | | srcPath | string | | src file path | | distPath | string | | dist file path | | injections | Object | | inject key and value | | [opts] | Object | {} | options | | [opts.plain] | boolean | false | Plain copy | | [opts.overwrite] | boolean | false | Force overwrite |
Example
// 'Hello, {{name:pascal}}!' > src.txt
const srcPath = 'src.txt'
const distPath = 'dist.txt'
await temjectCopy(srcPath, distPath, { name: 'world' })
// dist.txt -> 'Hello, World!'
temjectCopyRecursive(srcDir, distDir, injections [, opts])
| Param | Type | Default | Description | | ---------------- | -------------------- | ------------------ | -------------------------- | | srcDir | string | | src file directory or glob | | distDir | string | | dist directory path | | injections | Object | | inject key and value | | [opts] | Object | {} | options | | [opts.dry] | boolean | false | not copy | | [opts.plainCopy] | Array | false | not temject convert | | [opts.overwrite] | boolean | false | Force overwrite |
Example
await temjectCopyRecursive(
['./testFiles'],
'./sample',
{ name: 'MyName' },
{ dot: false, dry: true }
)
await temjectCopyRecursive(
['./src/__tests__/testFiles'],
'./sample',
{ name: 'MyName' },
{ plainCopy: [/ignore.txt$/] } // no convert setting
)
Related
License
MIT © mick-whats