@@ -2,7 +2,16 @@ var fs = require('fs')
22 , path = require ( 'path' )
33 , npm = require ( 'npm' )
44 , analyze = require ( './analyze' )
5- , util = require ( './util' ) ;
5+ , util = require ( './util' )
6+ , os = require ( 'os' )
7+
8+ // Use junctions on Windows < Vista (6.0),
9+ // Vista and later support regular symlinks.
10+ if ( os . platform ( ) == 'win32' && parseInt ( os . release ( ) ) < 6 ) {
11+ var symlinkType = 'junction'
12+ } else {
13+ symlinkType = 'dir'
14+ }
615
716module . exports = function install ( options , callback ) {
817
@@ -48,9 +57,7 @@ module.exports = function install(options, callback) {
4857 }
4958 fs . mkdirSync ( dotrnpm ) ;
5059 fs . mkdirSync ( path . join ( dotrnpm , 'node_modules' ) ) ;
51- fs . symlinkSync ( '.rnpm/node_modules' ,
52- path . join ( cwd , dir , 'node_modules' ) ,
53- 'junction' ) ;
60+ symlink ( '.rnpm/node_modules' , path . join ( cwd , dir , 'node_modules' ) ) ;
5461 // avoid npm warning, and provide some info
5562 // on the nature of the `.rnpm` dir
5663 fs . writeFileSync ( path . join ( dotrnpm , 'Readme.md' ) ,
@@ -59,9 +66,7 @@ module.exports = function install(options, callback) {
5966 'utf-8' ) ;
6067 } else {
6168 if ( ! fs . existsSync ( path . join ( cwd , dir , 'node_modules' ) ) ) {
62- fs . symlinkSync ( '.rnpm/node_modules' ,
63- path . join ( cwd , dir , 'node_modules' ) ,
64- 'junction' ) ;
69+ symlink ( '.rnpm/node_modules' , path . join ( cwd , dir , 'node_modules' ) ) ;
6570 }
6671 }
6772
@@ -100,3 +105,11 @@ module.exports = function install(options, callback) {
100105 } )
101106}
102107
108+ function symlink ( target , link ) {
109+ // Junction points must be absolute
110+ if ( symlinkType == 'junction' ) {
111+ target = path . resolve ( link , '..' , target )
112+ }
113+
114+ fs . symlinkSync ( target , link , symlinkType )
115+ }
0 commit comments