{"_id":"makef","_rev":"3-c01fa5ef4eaf67b17f0ea98e6cf352e4","name":"makef","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"makef","version":"1.0.0","description":"A utility to create files inside specified directory","main":"index.js","scripts":{"lint":"eslint --cache --max-warnings 0 index.js \"src/**/*.js\"","lint-error":"eslint --cache index.js \"src/**/*.js\"","lint-all":"eslint --max-warnings 0 index.js \"src/**/*.js\"","lint-all-error":"eslint index.js \"src/**/*.js\"","test":"jest","check":"npm run lint && npm test"},"repository":{"type":"git","url":"git://github.com/gamtiq/makef.git"},"keywords":["utility","create","make","produce","file","files","directory","write","output","content","empty"],"author":{"name":"Denis Sikuler"},"license":"MIT","bugs":{"url":"https://github.com/gamtiq/makef/issues"},"homepage":"https://github.com/gamtiq/makef#readme","dependencies":{"fs-extra":"8.x.x || 9.x.x"},"devDependencies":{"eslint":"6.x.x || 7.0.x","eslint-config-guard":"1.1.x","husky":"^4.2.5","jest":"26.x.x"},"gitHead":"4fcfa077fe90dc63084833a9e9fea5916db07705","_id":"makef@1.0.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","_npmUser":{"name":"gamtiq","email":"mforeg@yandex.ru"},"maintainers":[{"name":"gamtiq","email":"mforeg@yandex.ru"}],"dist":{"integrity":"sha512-i5y70loMn59Y7cA3L1tHCJygbONlZaA6GixFrjWNJ2x2BkSFZvgO/9LeWwAMyus7/Y++TIadv8jJsTtpLK0pug==","shasum":"7717e8e691e55b6feb91fe1d75024e3c2ce14286","tarball":"https://registry.npmjs.org/makef/-/makef-1.0.0.tgz","fileCount":10,"unpackedSize":36410,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeys4tCRA9TVsSAnZWagAAleQP/ROQAjwwyixbvvH6IoAF\naGUQ3yEIzS9O7Ci/eZ9t4NNdSH2K6t+BlwLmsAnTnnP2O90U9d0pwR4DdtD2\n6UkrsDyIi9O3EEyE2chUIaBFgGidshk/aWC+cyktpp00bG7Qds1JPTzGMpul\n+w0rEso0b2gm+uBpFxaNCJpZdIV5EwpCJ7nsg/At/7xuzpzP31DEDexoc9oi\nfLzX3/EHWmAngrCKU1B/vOEj648y4GpyAAhZipdrHUjl1FhRvIL0QwPV952d\ncagJaa9OXeMrL/m8mk+Y36AH+YFrfTsBXK/FhifCFUtlVPlqiIFOWRUH5QBS\n+FfNvUsxiKsm42lYclabm5XX59u5DbCbD4XXpzaMjh5G2nJ4mcGFDhzaa5XF\ndPUroQALgbWhlxLf1GDNvIIErPR/cgkXMhBUkCM1n2sf1YfEXr32KG4RC0PR\nDlKs52+enRaaYlwqKr65i4bdcUFsOrO43ZDmxP8xmAHICuZah4sEVKgBPAcj\ngw9bKDeLCca0ZkydeTISvx0FjqiHlRtyRKinPfx97O8rK9OP1F3wGUBb8akM\nO/1RIfn8WhHix1l2GsTKX2Zfk5+aswSK53QyHbVXl3FycPxiaEY+UxwnBsWI\nH/E0BPM0cs08JCQFyAlgjOTeV5M74dUITDHk9/B+NMAYwv8btqGMMnof0H3O\nlgB+\r\n=/oyh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFTaVe3XInJIQeqfcPv5DGa2VoS3tIZfvKY8e0J/JYiQAiAWAL4MO40Yl8pGcqHaFIuaBDqDyoNp9tWxmubdfTK4dw=="}]},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/makef_1.0.0_1590349357170_0.620244141482577"},"_hasShrinkwrap":false},"1.1.0":{"name":"makef","version":"1.1.0","description":"Utilities to create files inside specified directory or copy files","main":"index.js","types":"./index.d.ts","scripts":{"lint":"eslint --cache --max-warnings 0 index.js \"src/**/*.js\"","lint-error":"eslint --cache index.js \"src/**/*.js\"","lint-all":"eslint --max-warnings 0 index.js \"src/**/*.js\"","lint-all-error":"eslint index.js \"src/**/*.js\"","test":"jest","check":"npm run lint && npm test"},"repository":{"type":"git","url":"git://github.com/gamtiq/makef.git"},"keywords":["utility","create","copy","make","produce","file","files","directory","write","output","content","empty"],"author":{"name":"Denis Sikuler"},"license":"MIT","bugs":{"url":"https://github.com/gamtiq/makef/issues"},"homepage":"https://github.com/gamtiq/makef#readme","dependencies":{"fs-extra":"8.x.x || 9.x.x"},"devDependencies":{"eslint":"^7.14.0","eslint-config-guard":"^2.0.1","eslint-plugin-node":"^11.1.0","husky":"^4.3.0","jest":"^26.6.3"},"gitHead":"dbcf3eac0039488d7c06757a7996bfcf8bd51820","_id":"makef@1.1.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"integrity":"sha512-Hy6u6YaUhPSncFcsT6fakLnbtgFH9lNiaS76l7irikoVwFSWtOKJUs9xhbBsGN5WnEoWMKAL/UFcRsIC2KRLzw==","shasum":"c01d2c6a1d761de6fd00b305d1aa5fea0ec6649c","tarball":"https://registry.npmjs.org/makef/-/makef-1.1.0.tgz","fileCount":12,"unpackedSize":51847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfy2RXCRA9TVsSAnZWagAAfLEP/0ETyRmDqihCtIxINV5y\nDpzgPrw3MT1h0pCvx3Ci0M1xP5pRD8TQM0tUIU/VhGdEvLdnXeEIxwm8l5BX\nRld+4bx+Byhbc5abkWqaSfPqWEivpivqKoXCYYitlb4YRZkBM8feCZaIcHjl\nxcE3kekKtOhvwgkZUtmOG34S8Qr7alYV0BQtsfyZSaoXAwYaZq2udkS6uQgD\nDuOOKuhF6RnSSa+R27B1x4mAspGL5u3SXl9lK7jaa5F5+Ss+ITXF6SaT55oU\nM639XF/GpM3ElJMjO+Nk3+rRvYTld7uPpudbUXhvu9szQ8w6/UnWuCvMF5B9\nfpRZbgmRLLxyLR66Ylh2l2SqdfCldPsCezdCwqWvgMVQFIyht5XirkgV9IQ9\nd6rI5TOEFP9bolhvoGvhaK9rynMPemLg46XcBB+m7A2JKL5lWK0nfwm0MeWd\nLHuUAx7SIote7XprEPqJIvcUfbbJEqzokjNzF9i5V2VJfhYlQ1vxB5M9VgyQ\ndKcNFMZKU0jjeo7kXrid90z//rEj1+trT5im6Cib6XYyjAGT9wCks8EEtbi5\nx29pWmqYpjZLGViX1EcaCwfrpFrERfJ0rtbQCwKisr7Mn5NlSvigMAdKKUQT\nME0uB2wDSGznS3PYqQBakaYMwfY6l7RMNhWFhIM83Jy3hD1xsfCcEUOTp0v1\nxtCN\r\n=BADn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC4uzkw9KkR5h6q3e22umsdFmkgsK8eE7pdtxNp4JwjBAiEAw+enBwtohEiVdaXvrDT1Qzy+S0CZewJMDIo3mkbbAkk="}]},"_npmUser":{"name":"gamtiq","email":"mforeg@yandex.ru"},"directories":{},"maintainers":[{"name":"gamtiq","email":"mforeg@yandex.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/makef_1.1.0_1607165015279_0.2848185140477366"},"_hasShrinkwrap":false},"1.2.0":{"name":"makef","version":"1.2.0","description":"Utilities to create files inside specified directory or copy files","main":"index.js","types":"./index.d.ts","scripts":{"lint":"eslint --cache --max-warnings 0 index.js \"src/**/*.js\"","lint-error":"eslint --cache index.js \"src/**/*.js\"","lint-all":"eslint --max-warnings 0 index.js \"src/**/*.js\"","lint-all-error":"eslint index.js \"src/**/*.js\"","test":"jest","check":"npm run lint && npm test","prepare":"husky install"},"repository":{"type":"git","url":"git://github.com/gamtiq/makef.git"},"keywords":["utility","create","copy","make","produce","file","files","directory","write","output","content","empty"],"author":{"name":"Denis Sikuler"},"license":"MIT","bugs":{"url":"https://github.com/gamtiq/makef/issues"},"homepage":"https://github.com/gamtiq/makef#readme","dependencies":{"fs-extra":"8.x.x || 9.x.x || 10.x.x"},"devDependencies":{"eslint":"^7.28.0","eslint-config-guard":"^2.1.0","eslint-plugin-node":"^11.1.0","husky":"^6.0.0","jest":"^27.0.4"},"gitHead":"ae4ab0405266c86944e08814ff25c4153facd076","_id":"makef@1.2.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"integrity":"sha512-AUZh67ALq7kvOoanA9ZIvK6+PH6n+/UUi54fHpP5VJvS/Hhu8iF4c9vjm0n451r1RM6GqV4VoqW8mM4vtV8gbg==","shasum":"5f0fa4f39ae32eaff4472726e8ef20fb40d19ca1","tarball":"https://registry.npmjs.org/makef/-/makef-1.2.0.tgz","fileCount":12,"unpackedSize":51966,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgy6n4CRA9TVsSAnZWagAA+skP/2Rh26or6E5OM/YOlij5\nQHDlnt04MybMTxa++h1Mi9dL5WVJ47v4QYIob9VIUQHITRp2hvr68KFV8wwE\n/oymDEJrFdaKkvapX3J0udX7m/rPF6cEeSLd7nue8xIKhDqPqtKnSbD/5WYd\niSAWphe2ONHt1wyep32Qo+F0MT9AqNewt52Fq8DAPPItUvgBzAQC2DSOeIMJ\nEXukYAerAZcsC7ES+zg2TP/JllGhZF6mRsZblTZ2i9Hh8wvKVIi5vLHtmrOo\n7jrI1Nr+hDcoiIVtKT1ZCgoyAngO/XO0I9DC0M3CKiG197M0q3hY0tr42jn4\nkYuQZPGzk8u9+jKVXQReOhTtaMZ5LIRUoRn3EK7YUHdWTI6gG2B8iGWjt6Bm\nujKnfU1/Chb8vHj7D0TVMrjF22mWtjqleHEuc7ewQ4y5ymC+phnw8Ew63OCP\nbN8Tzt8/KqJciFoAJb1mAth5XJSlrqThfkFZwVQt5N9leBzBeTI3bxPJmyUt\nfKfJA+3XrpT6OkoEgg5cweIO7sWGhCG4ku5PH370NeQgjB3y+ItKqHdNGZ1s\nWYTGPBg58EeoiXC82CnHzwXY/Yi/W9BwCERoN20kRtb0fVGJLF5J+/KFRZqr\n+24XdCFy3HgPZlkIgekZ0qdQwa0663Q7gJhR1arHdvSNrELQZrPmp7kHcYgk\nXR44\r\n=Ni+O\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDQ5oa47kQIXRUAUjg8u0RIgsUSrq9Sdnq9dVQyxuRASgIgVPHcLRN/VSUHuQDhT2XkQatQO9Hm6tczA7tg5a9b9T0="}]},"_npmUser":{"name":"gamtiq","email":"mforeg@yandex.ru"},"directories":{},"maintainers":[{"name":"gamtiq","email":"mforeg@yandex.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/makef_1.2.0_1623960055568_0.8510065708068966"},"_hasShrinkwrap":false}},"time":{"created":"2020-05-24T19:42:37.170Z","1.0.0":"2020-05-24T19:42:37.368Z","modified":"2022-05-08T17:54:44.142Z","1.1.0":"2020-12-05T10:43:35.433Z","1.2.0":"2021-06-17T20:00:55.753Z"},"maintainers":[{"name":"gamtiq","email":"mforeg@yandex.ru"}],"description":"Utilities to create files inside specified directory or copy files","homepage":"https://github.com/gamtiq/makef#readme","keywords":["utility","create","copy","make","produce","file","files","directory","write","output","content","empty"],"repository":{"type":"git","url":"git://github.com/gamtiq/makef.git"},"author":{"name":"Denis Sikuler"},"bugs":{"url":"https://github.com/gamtiq/makef/issues"},"license":"MIT","readme":"# makef <a name=\"start\"></a>\n\nUtilities to create files inside specified directory or copy files.\n\nFeatures:\n* Create synchronously one file or several files at once.\n* Any content for a file is automatically converted to string. `JSON.stringify` is used to convert objects or arrays.\n* It is possible to skip creating of some files by specifying `false`, `null` or `undefined` as content value.\n* Determine whether a file should be created and/or form a file content dynamically by using a function as value for the file.\n* Specify any correct path as a file name. The path will be resolved regarding current working directory. Any subdirectory will be automatically created.\n* Create a copy of another file by using `copyFile`.\n\n```js\n// Create several files in current working directory\nmakef.createFile({\n    // The following file will be created with empty content\n    'a.txt': '',\n    // The following file will be created in subdirectory b\n    'b/c.log': 'some data',\n    // The following file will not be created\n    'd.file': false,\n    // The object that is specified as content will be converted to JSON\n    'file.json': {some: 'data'},\n    // The following file will be copied\n    'copy.data': makef.copyFile('../some/dir/source.file')\n});\n```\n\n[See more examples below.](#examples)\n\n## Table of contents\n\n* [Usage](#usage)\n* [Examples](#examples)\n* [API](#api)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Usage <a name=\"usage\"></a> [&#x2191;](#start)\n\nInstallation:\n\n    npm install makef\n\nNext in a module:\n\n```js\nconst makef = require('makef');\nconst { createFile, copyFile } = makef;\n```\n\n## Examples <a name=\"examples\"></a> [&#x2191;](#start)\n\nCreate one empty file:\n```js\ncreateFile('.nojekyll');\n```\nor\n```js\ncreateFile({'.nojekyll': ''});\n```\nor\n```js\ncreateFile({'.nojekyll': true});\n```\n\nCreate several files at once:\n```js\ncreateFile({\n    '.nojekyll': true,\n    'LICENSE': 'Some license data here',\n    'very/important/file.txt': 'very important data',\n    'config.json': {\n        a: 2,\n        topics: ['home', 'docs'],\n        url: 'http://some.server.net'\n    },\n    'subdir/another.log': makef.copyFile('./path/to/logs/data.log')\n});\n```\n\nSkip creating some files by setting `false`/`null` value for them:\n```js\ncreateFile({\n    '.nojekyll': false,\n    'a.txt': 'content',\n    'some/dir/file.md': null\n});\n```\n\nSpecify directory where files should be created:\n```js\ncreateFile(\n    {\n        '.nojekyll': '',\n        'data.json': {\n            a: 1,\n            b: {\n                c: 3\n            }\n        },\n        'subdir/file.data': 123\n    },\n    {\n        dir: '/path/to/some/dir'\n    }\n);\n```\n\nForm content for a file dynamically or skip creation by using a function:\n```js\nconst path = require('path');\n\nfunction getContent(file, env) {\n    return env.data.filter(env.filePath)\n        ? env.data.getData(file)\n        : null;\n}\n\ncreateFile(\n    {\n        'a.txt': getContent,\n        'b.log': 'static data',\n        'c.data': getContent,\n        'some/dir/file.txt': getContent\n    },\n    {\n        data: {\n            filter: (file) => path.extname(file) === '.txt',\n            getData: (file) => `content of ${file}`\n        }\n    }\n);\n```\n\nCopy a file:\n```js\nmakef.copyFile(\n    'source.txt',\n    'data.txt',\n    {\n        sourceDir: './from/some/dir',\n        dir: '../target/data/dir'\n    }\n);\n```\n\nSee additional examples in tests.\n\n## API <a name=\"api\"></a> [&#x2191;](#start)\n\n### `createFile(fileSet, settings?): object`\n\nCreate specified files.\n\nArguments:\n\n* `fileSet: object | string` - Name of empty file or set of files that should be created.\n    \n    If a string is passed it is treated as name of the only empty file that should be created.\n    When an object is passed its fields are used as file names and field values determine contents\n    for corresponding files.\n\n    When a function is specified as field value it will be called to get content for the file.\n    The following parameters are passed into a function:\n    - `fileName: string` - name of file that should be created as specified in a field name of `fileSet`.\n    - `env: object` - additional contextual data.\n    - `env.data: any` - value of `settings.data` (see below).\n    - `env.dir: string` - directory where file should be created; it is value of `settings.dir` (see below)\n        or empty string.\n    - `env.dirPath: string` - absolute path to directory where file should be created.\n    - `env.filePath: string` - absolute path to file that should be created.\n    - `env.logger: object` - An object having methods `log` (or `info`) and `error` that can be used for logging.\n        See `settings.logger` below for details.\n\n    A value returned from the function will be processed to form file content.\n\n    Content values (specified as a field value or returned from a function) are treated in the following way:\n    - `false`, `null` or `undefined` - means that the corresponding file should not be created.\n    - `true` - means that the corresponding file should be created with empty content.\n    - an object or an array - is converted to JSON that is used as file content.\n    - any other value - is converted to string that is used as file content.\n* `settings?: object` - Operation settings.\n* `settings.context?: object` - Object that should be used as `this` when calling a function to get a file content.\n* `settings.data?: any` - Any data that should be passed to a function that is used to get a file content.\n* `settings.dir?: string` - Directory that will be used to resolve (form) absolute path for relative file names.\n    I.e. it is base/target directory for created files.\n    By default the current working directory is used.\n* `settings.logger?: object` - An object having methods `log` (or `info`) and `error` that should be used for logging.\n    Pass `false` to disable logging.\n    Skipping this option or passing any other falsy value (i.e. `null`, `undefined`, `0`, etc)\n    or `true` will cause to use `console` as logger.\n\nReturns object representing creation result, or `undefined` when `fileSet` is not specified and no file is processed.\nObject fields are file names as specified in `fileSet`,\na field value is absolute path of the corresponding file,\nor error object when the file is not created by some reason.\n\n### `copyFile(sourceFile, destFile?, settings?): Function | void`\n\nCopy specified file.\n\nArguments:\n\n* `sourceFile: string` - Name/path of file that should be copied.\n* `destFile?: string` - Name/path of destination file that should be created.\n    If the file is not set a partially applied function will be returned\n    that can be used to copy source file several times by passing a destination file and settings as arguments.\n* `settings?: object` - Operation settings.\n* `settings.dir?: string` - Directory where destination file should be created.\n    By default the current working directory is used.\n* `settings.logger?: object` - An object having methods `log` (or `info`) and `error` that should be used for logging.\n    See the corresponding setting of `createFile` for details.\n* `settings.sourceDir?: string` - Directory where source file is located.\n\nReturns a partially applied function when `destFile` is not specified.\n\n## Contributing <a name=\"contributing\"></a> [&#x2191;](#start)\nIn lieu of a formal style guide, take care to maintain the existing coding style.\nAdd unit tests for any new or changed functionality.\nLint and test your code.\n\n## License <a name=\"license\"></a> [&#x2191;](#start)\nCopyright (c) 2020 Denis Sikuler  \nLicensed under the MIT license.\n","readmeFilename":"README.md"}