Know what OS we are working On?

filesystem
#1

Can we able to get Os Name XD is currently running

Edit :slight_smile:

async function checkPlatform() {
    const storage = await require("uxp").storage;
    const pluginFolder = await storage.localFileSystem.getPluginFolder();
    var path = pluginFolder.nativePath;

var result = "";
if (path.startsWith("/Users")) {
    result = "mac"
} else if (path.startsWith("C:\\Users")) {
    result = "windows";
} else {
    result = "this_is_madness";
}
return result;

}

to get platform =>

checkPlatform().then(
            result => {
                console.log(result);
            }
        );
1 Like
For People who wants to use Fonts in their plugin
#2

Could we compare the plugin folder’s native path?

#3

this is also i was thinking about @PaoloBiagini

#4

do you using mac what pattern mac outputs

#5

#6

so if we call pluginfloder from api in mac it output as above
@PaoloBiagini
where did you find this

#7

found that in plugin location docs

#8

post updated see the code above if not to know what platform XD is Running

#9

@PaoloBiagini test the code on mac if it is working ot not

#10

Hi @PramUkesh,

it works fine!!!
Just one detail: on Mac the starting tilde means '/Users/username’
So, update the following:
if (pluginFolderPath.startsWith("/Users"))
and that’s it.

Thank you again.

#11

There’s an easier way to get the current platform:

const platform = require("os").platform();
// will be "darwin" or "win10"
3 Likes
#12

Thank you very much @kerrishotts!

#13

Hi, it doesn’t work for me on Win 10 (version 1803) and on MacOs (version 10.14 18A391)

with this code

const platform = require("os").platform();

I obtain this in the console:

browser

instead of:

// will be "darwin" or "win10"
#14

Are you using webpack or another bundler? If so, make sure “os” is an external dependency (otherwise you might not be seeing our module).

#15

@kerrishotts is os module in api is an npm module or a custom built by adobe because i want to use process module in npm with present api(different form package.json model) its bit hard to implement

#16

The os module in XD is custom, and currently only provides information on the current platform and the OS release.

Fixing common TS typings
#17

Yes, the problem was webpack, thanks for the tips!

1 Like
#18

Is os a module or a global class? If a module, is it a top-level module or is it something in the uxp “namespace”?

The documentation claims that it is a “global class” rather than a module. This may be confusing several people (example).

Perhaps a documentation fix is in order?

#19

Sorry for the delay here – yes, the documentation is strange here. It’s a quirk of the docs generation process. We’re working on improving this over time.

The os module is behind require('os'), just like you’d do on Node.

1 Like
Fixing common TS typings