Code Monkey home page Code Monkey logo

node-mdls's Introduction

mdls

OSX's mdls from node.

A thin wrapper around mdls.

You give it a path, it runs mdls and calls a callback with the result.

Install

npm install --save mdls

Usage

Basic example

try {
    const data = await mdls('./index.js');
    console.log('Data', data);
} catch (err) {
    console.log('Error', err);
}

If all goes well, this will log:

{ ItemContentCreationDate: Sat May 17 2014 14:32:53 GMT-0700 (PDT),
  ItemContentModificationDate: Sat May 17 2014 15:01:52 GMT-0700 (PDT),
  ItemContentType: 'com.netscape.javascript-source',
  ItemContentTypeTree:
   [ 'com.netscape.javascript-source',
     'public.source-code',
     'public.plain-text',
     'public.text',
     'public.data',
     'public.item',
     'public.content',
     'public.executable' ],
  ItemDateAdded: Sat May 17 2014 14:32:53 GMT-0700 (PDT),
  ItemDisplayName: 'index.js',
  ItemFSContentChangeDate: Sat May 17 2014 15:01:52 GMT-0700 (PDT),
  ItemFSCreationDate: Sat May 17 2014 14:32:53 GMT-0700 (PDT),
  ItemFSCreatorCode: '',
  ItemFSFinderFlags: 0,
  ItemFSHasCustomIcon: 0,
  ItemFSInvisible: 0,
  ItemFSIsExtensionHidden: 0,
  ItemFSIsStationery: 0,
  ItemFSLabel: 0,
  ItemFSName: 'index.js',
  ItemFSNodeCount: 1554,
  ItemFSOwnerGroupID: 20,
  ItemFSOwnerUserID: 501,
  ItemFSSize: 1554,
  ItemFSTypeCode: '',
  ItemKind: 'JavaScript',
  ItemLogicalSize: 1554,
  ItemPhysicalSize: 4096 }

Each date above is a JavaScript date object. You can get the Unix timestamp out with the getTime method of each object.

Note that running mdls the command line utility would have returned:

kMDItemContentCreationDate     = 2014-05-17 21:32:53 +0000
kMDItemContentModificationDate = 2014-05-17 22:01:52 +0000
kMDItemContentType             = "com.netscape.javascript-source"
kMDItemContentTypeTree         = (
    "com.netscape.javascript-source",
    "public.source-code",
    "public.plain-text",
    "public.text",
    "public.data",
    "public.item",
    "public.content",
    "public.executable"
)
kMDItemDateAdded               = 2014-05-17 21:32:53 +0000
kMDItemDisplayName             = "index.js"
kMDItemFSContentChangeDate     = 2014-05-17 22:01:52 +0000
kMDItemFSCreationDate          = 2014-05-17 21:32:53 +0000
kMDItemFSCreatorCode           = ""
kMDItemFSFinderFlags           = 0
kMDItemFSHasCustomIcon         = 0
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 0
kMDItemFSIsStationery          = 0
kMDItemFSLabel                 = 0
kMDItemFSName                  = "index.js"
kMDItemFSNodeCount             = 1554
kMDItemFSOwnerGroupID          = 20
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = 1554
kMDItemFSTypeCode              = ""
kMDItemKind                    = "JavaScript"
kMDItemLogicalSize             = 1554
kMDItemPhysicalSize            = 4096

Example with arguments

You can also pass in arguments (as a string):

try {
    const data = await mdls('./index.js', '-name kMDItemContentTypeTree');
    console.log('Data', data);
} catch (err) {
    console.log('Error', err);
}

node-mdls's People

Contributors

awinterman avatar brettz9 avatar dependabot[bot] avatar takkaria avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

node-mdls's Issues

Repo missing `package.json`

Your repo is missing a package.json (despite the package being available on npm). When cloning your repo and trying to target my fork via npm, I got an error about this. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.