Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

myst-cli-utils

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

myst-cli-utils - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

13

dist/filesystem.d.ts

@@ -6,2 +6,3 @@ /// <reference types="node" resolution-mode="require"/>

export declare function computeHash(content: string): string;
export declare function isDirectory(file: string): boolean;
/** Writes a file ensuring that the directory exists */

@@ -15,2 +16,14 @@ export declare function writeFileToFolder(filename: string, data: string | NodeJS.ArrayBufferView, opts?: fs.WriteFileOptions): void;

export declare function hashAndCopyStaticFile(session: ISession, file: string, writeFolder: string): string | undefined;
/**
* Copy "file" maintaining original relative path to "from" directory with final "to" directory
*
* If "file" is not inside "from" folder, the file is not copied.
*/
export declare function copyFileMaintainPath(session: ISession, file: string, from: string, to: string): string | undefined;
/**
* Copy "file" to "to" directory.
*
* If a file already exists with the basename of "file" inside "to" directory, it is not copied.
*/
export declare function copyFileToFolder(session: ISession, file: string, to: string): string | undefined;
//# sourceMappingURL=filesystem.d.ts.map

@@ -7,2 +7,5 @@ import fs from 'node:fs';

}
export function isDirectory(file) {
return fs.lstatSync(file).isDirectory();
}
/** Writes a file ensuring that the directory exists */

@@ -44,1 +47,49 @@ export function writeFileToFolder(filename, data, opts) {

}
/**
* Copy "file" maintaining original relative path to "from" directory with final "to" directory
*
* If "file" is not inside "from" folder, the file is not copied.
*/
export function copyFileMaintainPath(session, file, from, to) {
// File must be inside "from" folder
if (!path.resolve(file).startsWith(path.resolve(from))) {
session.log.error(`Cannot include files outside of 'from' directory: ${file}\n\n`);
return undefined;
}
const destination = path.resolve(to, path.relative(from, file));
const destinationFolder = path.dirname(destination);
try {
if (!fs.existsSync(destinationFolder))
fs.mkdirSync(destinationFolder, { recursive: true });
fs.copyFileSync(file, destination);
session.log.debug(`File successfully copied: ${file}`);
return destination;
}
catch {
session.log.error(`Error copying file: ${file}`);
return undefined;
}
}
/**
* Copy "file" to "to" directory.
*
* If a file already exists with the basename of "file" inside "to" directory, it is not copied.
*/
export function copyFileToFolder(session, file, to) {
const destination = path.join(to, path.basename(file));
if (fs.existsSync(destination)) {
session.log.error(`File already exists with name: ${path.basename(file)}`);
}
const destinationFolder = path.dirname(destination);
try {
if (!fs.existsSync(destinationFolder))
fs.mkdirSync(destinationFolder, { recursive: true });
fs.copyFileSync(file, destination);
session.log.debug(`File successfully copied: ${file}`);
return destination;
}
catch {
session.log.error(`Error copying file: ${file}`);
return undefined;
}
}

2

dist/index.d.ts

@@ -7,3 +7,3 @@ export type { Logger, LoggerDE, ISession } from './types.js';

export { Session, getSession } from './session.js';
export { computeHash, hashAndCopyStaticFile, writeFileToFolder } from './filesystem.js';
export { computeHash, copyFileMaintainPath, copyFileToFolder, hashAndCopyStaticFile, isDirectory, writeFileToFolder, } from './filesystem.js';
//# sourceMappingURL=index.d.ts.map

@@ -6,2 +6,2 @@ export { LogLevel, basicLogger, chalkLogger, silentLogger, createGitLogger, createNpmLogger, } from './logger.js';

export { Session, getSession } from './session.js';
export { computeHash, hashAndCopyStaticFile, writeFileToFolder } from './filesystem.js';
export { computeHash, copyFileMaintainPath, copyFileToFolder, hashAndCopyStaticFile, isDirectory, writeFileToFolder, } from './filesystem.js';
{
"name": "myst-cli-utils",
"version": "2.0.1",
"version": "2.0.2",
"sideEffects": false,

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc