New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-file-helper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-file-helper - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

LICENSE.md

35

lib/file_helper.d.ts

@@ -22,30 +22,6 @@ /// <reference types="cordova-plugin-file" />

}
export interface EntryTree {
[path: string]: EntryTree | null;
}
/**
* Copyright notice for globToRegex
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (
* INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION
* )
* HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Simplify file access and directory navigation with native Promise support

@@ -180,2 +156,7 @@ */

/**
* Get a tree to see files below a certain directory
* @param path Base path for tree
*/
tree(path?: string): Promise<EntryTree>;
/**
* Remove a file or a directory.

@@ -182,0 +163,0 @@ * @param path Path of the file to remove. Do **NOT** remove root, use empty() !

@@ -12,3 +12,2 @@ "use strict";

})(FileHelperReadMode = exports.FileHelperReadMode || (exports.FileHelperReadMode = {}));
;
/**

@@ -26,2 +25,29 @@ * Glob to regex function.

function globToRegex(glob, flags = "") {
/*
* Copyright notice for globToRegex
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (
* INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION
* )
* HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
let str = glob;

@@ -126,29 +152,2 @@ // The regexp we are building, as a string.

/**
* Copyright notice for globToRegex
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (
* INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION
* )
* HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Simplify file access and directory navigation with native Promise support

@@ -417,3 +416,9 @@ */

return new Promise((resolve, reject) => {
window.resolveLocalFileSystemURL(path, resolve, reject);
window.resolveLocalFileSystemURL(path, resolve, err => {
if (err.code === FileError.NOT_FOUND_ERR || err.code === FileError.SYNTAX_ERR) {
reject(new Error("File not found"));
return;
}
reject(err);
});
});

@@ -447,14 +452,27 @@ }

const entry = await this.get(path);
const [e, l, f, d, r, p] = [
option_string.includes("e"), option_string.includes("l"), option_string.includes("f"),
option_string.includes("d"), option_string.includes("r"), option_string.includes("p")
];
if (entry.isFile) {
if (e) {
const dir = this.getDirUrlOfPath(path);
return {
[dir ? dir + "/" : ""]: [entry]
};
}
else if (l) {
return [this.getStatsFromFile(await this.getFileOfEntry(entry))];
}
return [path];
}
const e = option_string.includes("e");
const l = option_string.includes("l");
const f = option_string.includes("f");
const d = option_string.includes("d");
const r = option_string.includes("r");
const p = option_string.includes("p");
// Enlève le slash terminal et le slash initial (les chemins ne doivent jamais commencer par /)
path = path.replace(/\/$/, '');
path = path.replace(/^\//, '');
path = path.replace(/\/$/, '').replace(/^\//, '');
// Si jamais on veut chercher récursivement les entrées, avec un path non vide
// et qu'on veut en plus supprimer les préfixes
if (p && e && r && path) {
const new_root = new FileHelper(this.pwd() + "/" + path);
await new_root.waitInit();
return new_root.ls(undefined, "per");
}
let entries = await this.entriesOf(entry);

@@ -487,7 +505,7 @@ let obj_entries = { [path]: entries };

}
// Demande les stats du fichier
if (l) {
const paths = [];
for (const rel_path in obj_entries) {
for (const e of obj_entries[rel_path]) {
const paths = [];
for (const rel_path in obj_entries) {
for (const e of obj_entries[rel_path]) {
// Demande les stats du fichier
if (l) {
if (e.isDirectory) {

@@ -509,10 +527,4 @@ paths.push({

}
}
return paths;
}
// Sinon, on traite les entrées comme un string[]
else {
const paths = [];
for (const rel_path in obj_entries) {
for (const e of obj_entries[rel_path]) {
else {
// Sinon, on traite les entrées comme un string[]
// Enregistrement du bon nom

@@ -522,6 +534,36 @@ paths.push((rel_path && (!p || r) ? rel_path + "/" : "") + e.name);

}
return paths;
}
return paths;
}
/**
* Get a tree to see files below a certain directory
* @param path Base path for tree
*/
async tree(path = "") {
const flat_tree = await this.ls(path, "pre");
// Désaplatissement de l'arbre
const tree = {};
for (const p in flat_tree) {
let current_tree = tree;
// Si ce n'est pas la racine
if (p !== "") {
const steps = p.split('/');
for (const step of steps) {
// Construction des dossiers dans l'arbre
if (!(step in current_tree)) {
current_tree[step] = {};
}
current_tree = current_tree[step];
}
}
for (const entry of flat_tree[p]) {
// On ajoute les entrées dans current_tree
if (entry.isFile) {
current_tree[entry.name] = null;
}
}
}
return tree;
}
/**
* Remove a file or a directory.

@@ -528,0 +570,0 @@ * @param path Path of the file to remove. Do **NOT** remove root, use empty() !

{
"name": "cordova-file-helper",
"version": "1.0.0",
"version": "1.1.0",
"description": "",

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

@@ -39,2 +39,15 @@ # cordova-file-helper

replace export for FileHelperReadMode
```js
var FileHelperReadMode;
(function (FileHelperReadMode) {
FileHelperReadMode[FileHelperReadMode["text"] = 0] = "text";
FileHelperReadMode[FileHelperReadMode["array"] = 1] = "array";
FileHelperReadMode[FileHelperReadMode["url"] = 2] = "url";
FileHelperReadMode[FileHelperReadMode["binarystr"] = 3] = "binarystr";
FileHelperReadMode[FileHelperReadMode["json"] = 4] = "json";
FileHelperReadMode[FileHelperReadMode["internalURL"] = 5] = "internalURL";
})(FileHelperReadMode);
```
and the last one

@@ -41,0 +54,0 @@ ```js

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