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

converter-toless-plugin

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

converter-toless-plugin - npm Package Compare versions

Comparing version 0.1.2541 to 0.1.2543

69

lib/components/utils.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNameOf = exports.deleteAllFilesInDirectory = exports.deleteDirectory = exports.deleteFile = exports.getProps = void 0;
exports.deleteAllFilesInDirectory = exports.deleteDirectory = exports.deleteFile = exports.getProps = exports.getNameOf = void 0;
const path_1 = require("path");
const fs = require("fs");
function getNameOf(arry, name) {
let indexofar = -1;
arry.forEach((ar, i) => {
if (ar.name === name) {
indexofar = i;
}
});
return indexofar;
}
exports.getNameOf = getNameOf;
function getProps(name) {

@@ -17,8 +36,13 @@ const n = name.split(".");

try {
fs.unlink(filePath, (err) => {
if (err) {
r(err);
}
s();
});
if (!fs.statSync(filePath).isDirectory()) {
fs.unlink(filePath, (err) => {
if (err) {
r(err);
}
s();
});
}
else {
r(`Trying to delete ${filePath} as file`);
}
}

@@ -34,3 +58,8 @@ catch (err) {

try {
fs.rmdir(dirPath, s);
if (fs.statSync(dirPath).isDirectory()) {
fs.rmdir(dirPath, s);
}
else {
r(`Trying to delete ${dirPath} as directory`);
}
}

@@ -45,3 +74,3 @@ catch (err) {

return new Promise((s, r) => {
fs.readdir(dir, (err, files) => {
fs.readdir(dir, (err, files) => __awaiter(this, void 0, void 0, function* () {
if (err)

@@ -51,24 +80,12 @@ r(err);

const pathi = path_1.join(dir, file);
if (!fs.statSync(pathi).isDirectory()) {
fs.unlink(pathi, err => {
if (err)
r(err);
});
}
if (fs.statSync(pathi).isDirectory())
yield deleteDirectory(pathi);
else
yield deleteFile(pathi);
}
s();
});
}));
});
}
exports.deleteAllFilesInDirectory = deleteAllFilesInDirectory;
function getNameOf(arry, name) {
let indexofar = -1;
arry.forEach((ar, i) => {
if (ar.name === name) {
indexofar = i;
}
});
return indexofar;
}
exports.getNameOf = getNameOf;
//# sourceMappingURL=utils.js.map
{
"name": "converter-toless-plugin",
"version": "0.1.2541",
"version": "0.1.2543",
"description": "this is a plugin",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -9,2 +9,11 @@ import { join } from "path"

export function getNameOf(arry: Compiler[], name: string) {
let indexofar = -1;
arry.forEach((ar, i) => {
if (ar.name === name) {
indexofar = i;
}
});
return indexofar;
}

@@ -20,2 +29,6 @@

// delete functions

@@ -25,8 +38,10 @@ export function deleteFile(filePath: string): Promise<void> {

try {
fs.unlink(filePath, (err) => {
if (err) {
r(err)
}
s()
})
if (!fs.statSync(filePath).isDirectory()) {
fs.unlink(filePath, (err) => {
if (err) {
r(err)
}
s()
})
} else { r(`Trying to delete ${filePath} as file`) }
} catch (err) {

@@ -39,7 +54,10 @@ r(err)

export function deleteDirectory(dirPath: string) {
export function deleteDirectory(dirPath: string): Promise<any> {
return new Promise((s, r) => {
try {
fs.rmdir(dirPath, s)
if (fs.statSync(dirPath).isDirectory()) {
fs.rmdir(dirPath, s)
} else {
r(`Trying to delete ${dirPath} as directory`)
}
} catch (err) {

@@ -51,16 +69,14 @@ r(err)

export function deleteAllFilesInDirectory(dir: string): Promise<void> {
return new Promise((s, r) => {
fs.readdir(dir, (err, files) => {
fs.readdir(dir, async (err, files) => {
if (err) r(err);
for (const file of files) {
const pathi = join(dir, file);
if (!fs.statSync(pathi).isDirectory()) {
fs.unlink(pathi, err => {
if (err) r(err)
});
}
if (fs.statSync(pathi).isDirectory())
await deleteDirectory(pathi);
else
await deleteFile(pathi);
}
s()

@@ -72,11 +88,2 @@ });

export function getNameOf(arry: Compiler[], name: string) {
let indexofar = -1;
arry.forEach((ar, i) => {
if (ar.name === name) {
indexofar = i;
}
});
return indexofar;
}

@@ -83,0 +90,0 @@

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