npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

env-profile

v0.0.10

Published

An npm package to manage "environment variables" for Windows, "/etc/profile" for Linux, and ".bash_profile" for Mac.

Downloads

19

Readme

env-profile

NPM

Do not use while still under development

仍在开发 请勿使用

开发计划解决path超出1024问题 1、打开Path,将所有路径备份下来2、新建一个新的环境变量:Path_User 3、我们操作变量就放在Path_User中,并且将%Path_User%加入到Path变量中。

期待你的贡献, 欢迎所有人提交代码PR

Looking forward to your contribution, all people are welcome to submit code PR

An npm package to manage "environment variables" for Windows, "/etc/profile" for Linux, and ".bash_profile" for Mac.

用于管理 Windows 的“环境变量”、Linux 的“/etc/profile”和 Mac 的“.bash_profile”的 npm 包。

Installation 安装

npm install env-profile

Usage 用法

import { getOSType, setUserEnv, setSysEnv, getEnvVariable, backupEnv, restoreEnv, mergeUserEnv, mergeSysEnv } from 'env-profile';

// 获取操作系统类型 (Get the operating system type)
const osType = getOSType();
console.log('操作系统类型:', osType);

// 设置用户环境变量 (Set user environment variable)
setUserEnv('KEY', 'VALUE')
    .then((result) => {
        if (result.success) {
            console.log(`成功设置用户环境变量 ${result.key}=${result.value}`); // Successfully set user environment variable
        } else {
            console.error(`无法设置用户环境变量 ${result.key}=${result.value}: ${result.error}`); // Failed to set user environment variable
        }
    });

// 设置系统环境变量 (Set system environment variable)
setSysEnv('KEY', 'VALUE')
    .then((result) => {
        if (result.success) {
            console.log(`成功设置系统环境变量 ${result.key}=${result.value}`); // Successfully set system environment variable
        } else {
            console.error(`无法设置系统环境变量 ${result.key}=${result.value}: ${result.error}`); // Failed to set system environment variable
        }
    });
// 合并用户环境变量 (Set user environment variable)
// 给类似"JAVA_HOME"的场景使用 Give a similar scenario USES JAVA "HOME"
mergeUserEnv('PATH', '%KEY%\\bin')
    .then((result) => {
        if (result.success) {
            console.log(`成功设置用户环境变量 ${result.key}=${result.value}`); // Successfully set user environment variable
        } else {
            console.error(`无法设置用户环境变量 ${result.key}=${result.value}: ${result.error}`); // Failed to set user environment variable
        }
    });

// 合并系统环境变量 (Set system environment variable) 
// 给类似"JAVA_HOME"的场景使用 Give a similar scenario USES JAVA "HOME"
mergeSysEnv('PATH', '%KEY%\\bin')
    .then((result) => {
        if (result.success) {
            console.log(`成功设置系统环境变量 ${result.key}=${result.value}`); // Successfully set system environment variable
        } else {
            console.error(`无法设置系统环境变量 ${result.key}=${result.value}: ${result.error}`); // Failed to set system environment variable
        }
    });
// 获取环境变量 (Get environment variable)
const value = getEnvVariable('KEY');
console.log('环境变量值:', value); // Value of environment variable

// 备份环境变量 (Backup environment variables)
backupEnv()
    .then((backupPath) => {
        console.log('环境变量备份路径:', backupPath); // Environment variables backed up to
    });

// 恢复环境变量 (Restore environment variables)
restoreEnv('/path/to/backup')
    .then((restoredVariables) => {
        console.log('恢复的环境变量:', restoredVariables); // Restored environment variables
    });

License 许可

Copyright (c) 2023 [email protected]

Licensed under the MIT License.