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

code-engine-destination-filesystem

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-engine-destination-filesystem - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

39

lib/clean.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ono_1 = require("ono");
const path_1 = require("path");

@@ -12,9 +13,39 @@ const trash = require("trash");

let dir = path_1.resolve(context.cwd, config.path);
// Move the output directory to the OS trash.
// This is safer than permanently deleting it,
// and allows users to roll-back to previous output if they want.
await trash(dir, { glob: false });
let exists = await directoryExists(dir, config);
if (exists) {
// Move the output directory to the OS trash.
// This is safer than permanently deleting it,
// and allows users to roll-back to previous output if they want.
await trash(dir, { glob: false });
}
};
}
exports.clean = clean;
/**
* Determines whether the specified directory exists.
* An error is thrown if the path exists and is not a directory.
*/
async function directoryExists(dir, config) {
try {
let stats = await config.fs.promises.stat(dir);
if (stats.isDirectory()) {
// The directory exists
return true;
}
else {
throw ono_1.ono({ code: "ENOTDIR", path: dir }, `The destination path is not a directory: ${dir}`);
}
}
catch (err) {
let error = err;
if (error.code === "ENOENT") {
// The directory does not exist
return false;
}
else {
// Some other error occurred
throw err;
}
}
}
//# sourceMappingURL=clean.js.map
/// <reference types="node" />
import { Filter } from "@code-engine/types";
import { MakeDirectoryOptions, NoParamCallback, WriteFileOptions } from "fs";
import { MakeDirectoryOptions, NoParamCallback, Stats, WriteFileOptions } from "fs";
/**

@@ -32,2 +32,6 @@ * Configuration for the fileystem destination plugin.

/**
* Returns filesystem information about a directory entry.
*/
stat(path: string, callback: Callback<Stats>): void;
/**
* Creates a directory. Also creates its parent directories if the `recursive` option is set.

@@ -41,1 +45,5 @@ */

}
/**
* An error-first callback function.
*/
export declare type Callback<T> = (err: Error | null, result: T) => void;

3

lib/normalize-config.d.ts
/// <reference types="node" />
import { MakeDirectoryOptions, WriteFileOptions } from "fs";
import { MakeDirectoryOptions, Stats, WriteFileOptions } from "fs";
import { FS } from "./config";

@@ -9,2 +9,3 @@ /**

promises: {
stat(path: string): Promise<Stats>;
mkdir(path: string, option: MakeDirectoryOptions): Promise<void>;

@@ -11,0 +12,0 @@ writeFile(path: string, data: Buffer, options: WriteFileOptions): Promise<void>;

@@ -17,5 +17,7 @@ "use strict";

fs = {
stat: validate_1.validate.type.function(config.fs.stat, "fs.stat", nodeFS.stat),
mkdir: validate_1.validate.type.function(config.fs.mkdir, "fs.mkdir", nodeFS.mkdir),
writeFile: validate_1.validate.type.function(config.fs.writeFile, "fs.writeFile", nodeFS.writeFile),
promises: {
stat: util_1.promisify(validate_1.validate.type.function(config.fs.stat, "fs.stat", nodeFS.stat)),
mkdir: util_1.promisify(validate_1.validate.type.function(config.fs.mkdir, "fs.mkdir", nodeFS.mkdir)),

@@ -22,0 +24,0 @@ writeFile: util_1.promisify(validate_1.validate.type.function(config.fs.writeFile, "fs.writeFile", nodeFS.writeFile)),

{
"name": "code-engine-destination-filesystem",
"version": "0.0.6",
"version": "0.0.7",
"description": "A CodeEngine plugin that reads files from the filesystem",

@@ -70,4 +70,5 @@ "keywords": [

"@code-engine/validate": "^1.0.0",
"ono": "^5.1.0",
"trash": "^6.1.1"
}
}

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