writeProject
Writes a file map below directory.
Writes a file map below directory.
Everything is checked before the first byte is written: a path that would leave the project, two
names that differ only by case, or a directory that is not empty (without force), throws and
leaves the disk untouched. With force existing files of the same name are overwritten and other
files stay. If a write fails part-way (a permission, a disk, a file where a folder must go), the
files and folders this call created are removed again, and the error names the file.
Import#
ts
import { writeProject } from "create-shadow-app";
Signature#
ts
function writeProject(
directory: string,
files: ReadonlyMap<string, string>,
options: { force: boolean },
): WriteResult
Parameters#
| Name | Description |
|---|---|
directory |
Target directory (created when missing). |
files |
Relative POSIX path to content. |
options |
force allows writing into a non-empty directory. |
Returns#
The absolute directory and the files written.
Throws#
- Error
<dir> is not empty., a refused path, orCould not write <file>: <reason>.
Examples#
ts
writeProject("/work/app", new Map([["README.md", "# app\n"]]), { force: false });