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

platform-overrides

v1.0.1

Published

Allows you to specify platform-specific manifest values. Work with JSON or plain objects.

Downloads

644

Readme

platform-overrides

NPM version Build Status Windows Build Status Dependency Status


Apply platform-specific manifest values. Works with JSON or plain objects.

The platform-specific options will override the others only when "building" for that platform and the platformOverrides property will be removed.

This was originally created with node-webkit in mind.

Need a Gulp plugin? See gulp-platform-overrides.

Installation

npm install platform-overrides

Usage

var platformOverrides = require('platform-overrides');

var result = platformOverrides({
        options: '{"a": 0, "platformOverrides": { "osx": { "a": 1 } } }',
        platform: 'osx' // auto-detects a platform if omitted
    }, function(err, result){
        if(err) //...

        // result will be a JSON string but the "a" property will contain 1 now
    });

API

platformOverrides(options, callback)

Returns an Object or String, depending on the type of the options property you passed.

Options

options

Object or String. (i.e. options.options)

platform

(Optional) String. One of the following: [osx, osx32, osx64, win, win32, win64, linux, linux32, linux64].

If not passed, the current platform is detected (the auto-detected platform is always an architecture-specific one (i.e. has 32 / 64 on the end).

See Examples for how this parameter effects the behaviour of this plugin.

Note: osx is not mac just for the sake of backwards compatibility with node-webkit-builder.

Callback

Function called on completion with error and result arguments; e.g. function(err, result){}

Examples

Example manifest:

{
  "name": "nw-demo",
  "version": "0.1.0",
  "main": "index.html",
  "window": {
      "frame": false,
      "toolbar": false
  },
  "platformOverrides": {
      "win": {
          "window": {
              "frame": true
          }
      },
      "osx64": {
          ...
      },
      ...
  }
}

For example, when building for Windows (passing win as the platform or not passing a platform on a Windows machine), the manifest generated and put into the end app (from the manifest above) would be:

{
    "name": "nw-demo",
    "version": "0.1.0",
    "main": "index.html",
    "window": {
        "frame": true,
        "toolbar": false
    }
}

Architecture-agnostic

Example manifest:

{
  "name": "nw-demo",
  "platformOverrides": {
      "win": {
          "name": "hello"
      },
      "win32": {
          "name": "world"
      },
      "win64": {
          "name": "like"
      }
      ...
  }
}

If win is passed as the platform, then only win is applied and win32 & win64 are ignored;

{
    "name": "hello"
}

Specificity & Cascading

Example manifest:

{
  "name": "nw-demo",
  "version": "0.1",
  "platformOverrides": {
      "win": {
          "name": "hello",
          "version": "0.2"
      },
      "win32": {
          "version": "0.3"
      },
      "win64": {
          "name": "like"
      }
      ...
  }
}

If win32 is passed as the platform (or win32 is auto-detected), then win is applied first, then win32;

{
      "name": "hello",
      "version": "0.3"
}

Even if there is no win32, then the win platform overrides will still be applied.

Contributing

See CONTRIBUTING.md.