🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

os-paths

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

os-paths - npm Package Compare versions

Comparing version

to
4.4.0

9

package.json
{
"name": "os-paths",
"version": "4.3.0",
"version": "4.4.0",
"description": "Generate portable common OS paths (home, temp, ...)",

@@ -16,3 +16,3 @@ "license": "MIT",

"src/**/*",
"src/lib/index.d.ts",
"CHANGELOG.mkd",
"LICENSE",

@@ -31,3 +31,2 @@ "README.md"

"macos",
"nix",
"node6",

@@ -103,3 +102,2 @@ "osx",

"is-node-modern": "^1.0.0",
"lodash": "^4.17.15",
"npm-run-all": "^4.1.5",

@@ -109,4 +107,3 @@ "nyc": "^14.1.1",

"prettier": "^2.1.1",
"tsd": "^0.13.1",
"util": "^0.12.1"
"tsd": "^0.13.1"
},

@@ -113,0 +110,0 @@ "optionalDependencies": {},

@@ -12,3 +12,3 @@ <!DOCTYPE markdown><!-- markdownlint-disable no-inline-html -->

> Generate portable common OS paths (home and temp)
> Generate portable common OS paths (home, temp, ...)

@@ -20,3 +20,3 @@ [![Build status][gha-image]][gha-url]

[![License][license-image]][license-url]
[![Javascript Style Guide][style-image]][style-url]
[![Style Guide][style-image]][style-url]
&nbsp; <br/>

@@ -47,7 +47,7 @@ [![Repository][repository-image]][repository-url]

//(*nix) => '/home/rivy'
//(win) => 'C:\Users\RIvy'
//(win) => 'C:\Users\rivy'
osPaths.temp();
//(*nix) => '/tmp'
//(win) => 'C:\temp'
//(win) => 'C:\Windows\temp'
```

@@ -69,3 +69,3 @@

All module methods return simple, platform-compatible, path strings.
All module methods return simple, platform-compatible, path strings which are normalized and have no trailing path separators.

@@ -85,2 +85,4 @@ The path strings are _not_ guaranteed to already exist on the file system. So, the user is responsible for directory construction, if/when needed.

## Discussion
### XDG

@@ -90,2 +92,52 @@

## Building and Contributing
### Build requirements
- NodeJS >= 6.0
- a JavaScript package/project manager ([`npm`](https://www.npmjs.com/get-npm) or [`yarn`](https://yarnpkg.com))
> #### optional
>
> - [`git-changelog`](https://github.com/rivy-go/git-changelog) ... enables changelog automation
### Build/test
```shell
npm install
npm test
```
### Project development scripts
```shell
> npm run help
...
usage: `npm run TARGET [TARGET..]`
TARGETs:
coverage calculate and display (or send) code coverage [alias: 'cov']
fix fix package issues (automated/non-interactive)
fix:lint fix `ESLint` issues
fix:style fix `Prettier` formatting issues
help display help
lint check for package code 'lint'
lint:lint check for code 'lint' (using `ESLint`)
lint:spell check for spelling errors (using `cSpell`)
lint:style check for format imperfections (using `Prettier`)
lint:types check for type declaration errors (using `tsd`)
test test package
test:code test package code
update:changelog update CHANGELOG (using `git changelog ...`)
```
### Contributions
Contributions are welcome.
Any pull requests should be based off of the default branch (`master`). And, whenever possible, please include tests for any new code, ensuring that local (via `npm test`) and remote CI testing passes.
By contributing to the project, you are agreeing to provide your contributions under the same [license](./LICENSE) as the project itself.
## Related

@@ -98,3 +150,3 @@

MIT © [Roy Ivy III](https://github.com/rivy), [Sindre Sorhus](https://sindresorhus.com)
[MIT](./LICENSE) © [Roy Ivy III](https://github.com/rivy), [Sindre Sorhus](https://sindresorhus.com)

@@ -101,0 +153,0 @@ <!-- badge references -->

/* eslint-env es6, node */
// # spell-checker:ignore UserProfile HomeDrive HomePath WinDir
// # spell-checker:ignore HomeDrive HomePath LocalAppData UserProfile WinDir
'use strict';
const os = require('os');
const paths = require('path');
const isWinOS = /^win/i.test(process.platform);
function normalize_path(path) {
return paths.normalize(paths.join(path, '.'));
}
const base = () => {

@@ -14,28 +19,6 @@ const { env } = process;

object.home = os.homedir
? () => {
return os.homedir();
}
: () => {
let path = env.HOME;
if (path.length > 1 && path.endsWith('/')) {
path = path.slice(0, -1);
}
object.home = () => normalize_path(os.homedir ? os.homedir() : env.HOME);
return path;
};
object.temp = () => normalize_path(os.tmpdir ? os.tmpdir() : env.TMPDIR || env.TEMP || env.TMP);
object.temp = os.tmpdir
? () => {
return os.tmpdir();
}
: () => {
let path = env.TMPDIR || env.TEMP || env.TMP || '/tmp';
if (path.length > 1 && path.endsWith('/')) {
path = path.slice(0, -1);
}
return path;
};
return object;

@@ -49,36 +32,18 @@ };

object.home = os.homedir
? () => {
return os.homedir();
}
: () => {
let path = env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || env.HOME;
if (
path.length > 1 &&
((path.endsWith('\\') && !path.endsWith(':\\')) ||
(path.endsWith('/') && !path.endsWith(':/')))
) {
path = path.slice(0, -1);
}
object.home = () =>
normalize_path(
os.homedir
? os.homedir()
: env.USERPROFILE || paths.join(env.HOMEDRIVE, env.HOMEPATH) || env.HOME
);
return path;
};
object.temp = () =>
normalize_path(
os.tmpdir
? os.tmpdir()
: env.TEMP ||
env.TMP ||
paths.join(env.LOCALAPPDATA || env.SystemRoot || env.windir, 'Temp')
);
object.temp = os.tmpdir
? () => {
return os.tmpdir();
}
: () => {
let path = env.TEMP || env.TMP || (env.SystemRoot || env.windir) + '\\temp';
if (
path.length > 1 &&
((path.endsWith('\\') && !path.endsWith(':\\')) ||
(path.endsWith('/') && !path.endsWith(':/')))
) {
path = path.slice(0, -1);
}
return path;
};
return object;

@@ -85,0 +50,0 @@ };

Sorry, the diff of this file is not supported yet