Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 );
});
});
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");
}
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');
}
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);
}
async function readManifest(path) {
return await readFile(resolve(path, "pattern.json")).then(content =>
JSON.parse(content.toString("utf-8"))
);
}
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();
});
}
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));
}
return file => readFile(prefix, file);
}
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))
});
}
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));
}