Last active
August 9, 2021 00:57
Revisions
-
maraisr revised this gist
Aug 9, 2021 . 3 changed files with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ type FileType = string | Buffer | URL; type DataType = string | Buffer; declare function writeFile(path: FileType, body: DataType, content_type?: string): Promise<void>; declare function writeFileSync(path: FileType, body: DataType, content_type?: string): void; export { writeFile, writeFileSync }; This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,15 @@ import { mkdir, writeFile as _writeFile } from "fs/promises"; import { mkdirSync, writeFileSync as _writeFileSync } from "fs"; import { dirname } from "path"; export const writeFile = async (path, body, content_type) => { content_type = content_type || "utf8"; await mkdir(dirname(path), { recursive: true }); await _writeFile(path, body, content_type); }; export const writeFileSync = (path, body, content_type) => { content_type = content_type || "utf8"; mkdirSync(dirname(path), { recursive: true }); _writeFileSync(path, body, content_type); }; This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ { "name": "swrt", "version": "0.0.6", "repository": "https://gist.github.com/maraisr/e36f63d22673da3bc45f08f8cba9e083", "license": "MIT", "author": { -
maraisr revised this gist
Aug 6, 2021 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ { "name": "swrt", "version": "0.0.5", "repository": "https://gist.github.com/maraisr/e36f63d22673da3bc45f08f8cba9e083", "license": "MIT", "author": { @@ -9,7 +9,6 @@ "url": "https://marais.io" }, "sideEffects": false, "exports": { ".": { "import": "./dist/index.mjs", -
maraisr revised this gist
Aug 6, 2021 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ { "name": "swrt", "version": "0.0.4", "repository": "https://gist.github.com/maraisr/e36f63d22673da3bc45f08f8cba9e083", "license": "MIT", "author": { @@ -30,8 +30,5 @@ "devDependencies": { "@types/node": "^16.4.9", "bundt": "^1.1.5" } } -
maraisr revised this gist
Aug 1, 2021 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ { "name": "swrt", "version": "0.0.3", "repository": "https://gist.github.com/maraisr/e36f63d22673da3bc45f08f8cba9e083", "license": "MIT", "author": { @@ -18,7 +18,6 @@ "./package.json": "./package.json" }, "main": "dist/index.js", "module": "dist/index.mjs", "types": "index.d.ts", "files": [ -
maraisr revised this gist
Aug 1, 2021 . No changes.There are no files selected for viewing
-
maraisr revised this gist
Aug 1, 2021 . 2 changed files with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export const write = async (path, body, content_type) => { await writeFile(path, body, content_type); }; export const writeSync = (path, body, content_type) => { content_type = content_type || "utf8"; mkdirSync(dirname(path), { recursive: true }); writeFileSync(path, body, content_type); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ { "name": "swrt", "version": "0.0.2", "repository": "https://gist.github.com/maraisr/e36f63d22673da3bc45f08f8cba9e083", "license": "MIT", "author": { "name": "Marais Rossouw", -
maraisr revised this gist
Aug 1, 2021 . 4 changed files with 9 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes.File renamed without changes.This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ # SWRT <sup>Safe Write</sup> A safe-write, that classic `write the file`, but make any folders firstly. ```js import { write } from 'swrt'; await write('./dist/things.html', '<h1>hello world</h1>'); ``` -
maraisr created this gist
Aug 1, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ type FileType = string | Buffer | URL; type DataType = string | Buffer; declare function write(path: FileType, body: DataType, content_type?: string): Promise<unknown>; declare function writeSync(path: FileType, body: DataType, content_type?: string): unknown; export { write, writeSync }; This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ import { mkdir, writeFile } from "fs/promises"; import { mkdirSync, writeFileSync } from "fs"; import { dirname } from "path"; export const write = async (path, body, content_type) => { content_type = content_type || "utf8"; await mkdir(dirname(path), { recursive: true }); await writeFile(path, body, content_type); }; export const writeSync = async (path, body, content_type) => { content_type = content_type || "utf8"; mkdirSync(dirname(path), { recursive: true }); writeFileSync(path, body, content_type); }; This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ { "name": "swrt", "version": "0.0.1", "repository": "", "license": "MIT", "author": { "name": "Marais Rossouw", "email": "me@marais.dev", "url": "https://marais.io" }, "sideEffects": false, "type": "module", "exports": { ".": { "import": "./dist/index.mjs", "require": "./dist/index.js" }, "./package.json": "./package.json" }, "main": "dist/index.js", "unpkg": "dist/index.min.js", "module": "dist/index.mjs", "types": "index.d.ts", "files": [ "*.d.ts", "dist" ], "scripts": { "build": "bundt index.js" }, "devDependencies": { "@types/node": "^16.4.9", "bundt": "^1.1.5" }, "engines": { "node": ">16" } }