@lovely.sh/wrappers
My collection of personal wrappers
Last updated 10 months ago by lovely.sh .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @lovely.sh/wrappers 
SYNC missed versions from official npm registry.

Introduction

This is simply my personal compilation of wrappers and snippets

Installation

npm i "@lovely.sh/wrappers"

Usage

const wrapper = require('@lovely.sh/wrappers');

const resources = path.join(__dirname, 'resources');

// searchAndReplaceInFile
const textFile = path.join(resources, 'demo.txt');
wrapper.searchAndReplaceInFile(textFile, 'old text', 'new text');

// loadYaml ans writeYaml
const yamlFile = path.join(resources, 'demo.yaml');
const yamlContent = wrapper.loadYamlFile(yamlFile);

console.log(yamlContent.text);
yamlContent.version = '1.1.1';

wrapper.writeYamlFile(yamlFile, yamlContent);

// isExist
isExist = wrapper.exists(textFile);
if (isExist) {
  console.log('File/folder exist');
} else {
  console.log("File/folder don't exist");
}

// loadJsonFile and writeJsonFile
const jsonFile = path.join(resources, 'demo.json');
jsonContent = wrapper.loadJsonFile(jsonFile);

console.log(jsonContent.text);
jsonContent.version = '1.1.1';

wrapper.writeJsonFile(jsonFile, jsonContent);

// killProcess
try {
  const killProcess = await wrapper.killProcess('chrome.exe');
  console.log(killProcess.stdout);
} catch (error) {
  console.log(error);
}

// getPageContent()
try {
  console.log(await wrapper.getPageContent('https://httpbin.org/get', true));
} catch (error) {
  console.log(error);
}

// downloadFile
try {
  await wrapper.downloadFile('https://upload.wikimedia.org/wikipedia/commons/d/d2/Codinglogo.jpg', 'dev-image.jpg');
  console.log('Success to download file');
} catch (error) {
  console.log(error);
}

// isDev and isElectronPackaged
if (wrapper.isDev && !wrapper.isElectronPackaged) {
  console.log('Running on development');
} else {
  console.log('Running on production');
}

Current Tags

  • 3.0.1                                ...           latest (10 months ago)

18 Versions

  • 3.0.1                                ...           10 months ago
  • 3.0.0                                ...           10 months ago
  • 2.0.0                                ...           10 months ago
  • 1.0.15                                ...           a year ago
  • 1.0.13                                ...           a year ago
  • 1.0.12                                ...           a year ago
  • 1.0.11                                ...           a year ago
  • 1.0.10                                ...           a year ago
  • 1.0.9                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 18
Last Month 18
Dependencies (2)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |