How to use the sander.readFile function in sander

To help you get started, we’ve selected a few sander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esperantojs / esperanto / test / strictMode / index.js View on Github external
var promises = files.map( function ( file ) {
								if ( file === '_config.js' ) return;

								return sander.readFile( 'es6-module-transpiler-tests/input', dir, file ).then( String ).then( function ( source ) {
									var transpiled = esperanto.toCjs( source, {
										strict: true
									});

									return sander.writeFile( 'es6-module-transpiler-tests/output', dir, file, transpiled.code );
								});
							});
github patternplate / patternplate / packages / cli / source / library / init / get-readme-data.js View on Github external
export default async function getReadmeData(context = {}) {
  const readmePath = path.resolve(
    __dirname,
    "../../documentation/first-steps.md"
  );
  const readmeSource = await sander.readFile(readmePath, "utf-8");

  const readmeLines = readmeSource.split("\n").map(increment);

  return [`# ${context.name}`, readmeLines.join("\n")].join("\n");
}
github patternplate / patternplate / source / library / init / get-readme-data.js View on Github external
export default async function getReadmeData(context = {}) {
	const readmePath = path.resolve(__dirname, '../../documentation/first-steps.md');
	const readmeSource = await sander.readFile(readmePath, { encoding: 'utf-8' });

	const readmeLines = readmeSource
		.split('\n')
		.map(increment);

	return [`# ${context.name}`, readmeLines.join('\n')].join('\n');
}
github Rich-Harris / sorcery / dist / sorcery.js View on Github external
function getContent(node, sourcesContentByPath) {
	if (node.file in sourcesContentByPath) {
		node.content = sourcesContentByPath[node.file];
	}

	if (!node.content) {
		return sander.readFile(node.file).then(String);
	}

	return sander.Promise.resolve(node.content);
}
github patternplate / patternplate / packages / server / source / library / utilities / get-pattern-mtimes.js View on Github external
async function readManifest(path) {
  return await readFile(resolve(path, "pattern.json")).then(content =>
    JSON.parse(content.toString("utf-8"))
  );
}
github gobblejs / gobble / lib / nodes / serve / serveFile.js View on Github external
function serveFile(filepath, request, response) {
	return sander.readFile(filepath).then(function (data) {
		response.statusCode = 200;
		response.setHeader("Content-Type", mime.lookup(filepath));
		response.setHeader("Content-Length", data.length);

		response.write(data);
		response.end();
	});
}
github patternplate / patternplate / packages / server / source / library / utilities / get-pattern-tree.js View on Github external
async function getDoc(itemPath, context) {
  const baseName = context.type === "pattern" ? "index.md" : "readme.md";
  const file = path.resolve(itemPath, baseName);

  if (!await exists(file)) {
    return "";
  }
  return String(await sander.readFile(file));
}
github square / field-kit / script / build.js View on Github external
  return file => readFile(prefix, file);
}
github patternplate / patternplate / packages / server / source / application / routes / docs.js View on Github external
async function getDoc(id) {
  if (!id) {
    return null;
  }

  const file = resolve(id);

  if (!await exists(file)) {
    return null;
  }

  return vfile({
    path: path.posix.relative("./patterns", resolve(id)),
    contents: escapeHtml(await sander.readFile(file))
  });
}
github KnisterPeter / vscode-commitizen / src / extension.ts View on Github external
async function readPackageJson(): Promise {
  if (!vscode.workspace.workspaceFolders) {
    return undefined;
  }
  const pkgPath = join(vscode.workspace.workspaceFolders[0].uri.fsPath, 'package.json');
  if (!await sander.exists(pkgPath)) {
    return undefined;
  }
  return JSON.parse(await sander.readFile(pkgPath));
}

sander

Promise-based power tool for common filesystem tasks

MIT
Latest version published 7 years ago

Package Health Score

47 / 100
Full package analysis

Popular sander functions